Skip to content

Commit 1373880

Browse files
committed
v0.2
1 parent 805ec2d commit 1373880

File tree

15 files changed

+518
-275
lines changed

15 files changed

+518
-275
lines changed

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
# hog
1+
# The Power Hog
22

33
<img src="logo.png" width="100"/>
44

5-
The hog is a tool that periodically collects energy statistics of your mac and makes them available to you.
5+
The power hog is a tool that periodically collects energy statistics of your mac and makes them available to you.
66

77
There are two main aims:
88

99
1) Identify which apps are using a lot of energy on your machine.
10-
2) Collecting the data from as many machines as possible to identify wasteful apps.
10+
2) Collecting the data from as many machines as possible to identify wasteful apps globally.
1111

12-
The hog consists of 2 apps.
12+
We provide a website for detailed analytics of your data. The hog by default uploads your measurement data to our
13+
[Green Metrics Tool](https://github.com/green-coding-berlin/green-metrics-tool) backend. We put in a lot of effort
14+
to make sure that no confidential information is exposed but please refer to the [settings](#settings) section if you
15+
want to disable the upload or submit the data to your own [backend](https://docs.green-coding.berlin/docs/installation/installation-linux/).
16+
17+
The hog consists of 2 apps that run on your local system. You need to power logger but not the app!
1318

1419
## Power logger
1520

@@ -20,7 +25,20 @@ give some statistics. You can either call it by hand and send it to the backgrou
2025
For development purposes we recommend to always first run the program in the foreground and see if everything works fine
2126
and then use the launch agent.
2227

23-
### Launch agent
28+
If you want to avoid running the desktop app you can call the `power_logger.py` script with `-w` which will give
29+
you the details url.
30+
31+
You can also run the `powermetrics` process yourself and then use `power_logger.py` to process the data and upload it.
32+
You can use the `-f` parameter with a filename. Please submit the data in the plist format. You can use the following call string:
33+
`powermetrics --show-all -i 5000 -f plist -o FILENAME` and to run the powermetrics process yourself.
34+
35+
### Parameter list
36+
37+
- `-d`: Set's debug/ development mode to true. The Settings are set to local environments and we output statistics when running.
38+
- `-w`: Gives you the url of the analysis website and exits. This is especially useful when not using the desktop app
39+
- `-f filename`: Use the file as powermetrics input and don't start the process internally.
40+
41+
### Setup of the power collection script
2442

2543
This is a description on how to set everything up if you did a git clone. You can also just do
2644

@@ -29,6 +47,8 @@ curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/instal
2947
```
3048
which will do the whole install for you.
3149

50+
#### Do it manually
51+
3252
Make the `power_logger.py` script executable with `chmod a+x power_logger.py`
3353

3454
Please modify the `berlin.green-coding.hog.plist` file to reference the right path. There is a script below that does
@@ -69,16 +89,30 @@ sudo launchctl unload /Library/LaunchDaemons/berlin.green-coding.hog.plist
6989
### Settings
7090

7191
It is possible to configure your own settings by using a `settings.ini` file in the same directory as the `power_logger.py`
72-
script. Following keys are currently used:
92+
script or adding a `.hog_settings.ini` to your home folder. The home folder settings will be prioritized.
93+
94+
Following keys are currently used:
7395

7496
- `powermetrics`: This is the delta in ms that power metrics should take samples. So if you set this to 5000 powermetrics will return the aggregated values every 5 seconds
7597
- `upload_delta`: This is the time delta data should be uploaded in seconds.
7698
- `api_url`: The url endpoint the data should be uploaded to. You can use the https://github.com/green-coding-berlin/green-metrics-tool if you want but also write/ use your own backend.
99+
- `web_url`: The url where the analytics can be found. We will append the machine ID to this so make sure the end of the string is a `=`
77100

78101
## The desktop App
79102

80103
The hog desktop app gives you analytics of the data that was recorded. Please move this into your app folder.
81104

105+
### Description of the headings
106+
107+
- `Name`: This is the name of the process coalition. A coalition can be multiple processes. For example a program might fork
108+
new process which will all show up in the coalition. Sometimes a shell might turn up here. Please tell us so we can
109+
add this as an exception
110+
- `Energy Impact`: This is the value mac gives it's processes. The exact formula is not known but we know that quite some
111+
factors are considered. For now this is the best value we've got 🫣
112+
- `AVG Cpu Time %`: This is how long this coalition has spent on the CPUs. We take a percentage which can be over 100% as
113+
the coalition could run on multiple cpus at the same time. So if a process takes up 100% of cpu time and runs on 4 cpus
114+
the time will be 400%.
115+
82116
## Database
83117

84118
All data is saved in an sqlite database that is located under:

app/hog/hog.xcodeproj/project.pbxproj

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
attributes = {
199199
BuildIndependentTargetsInParallel = 1;
200200
LastSwiftUpdateCheck = 1430;
201-
LastUpgradeCheck = 1430;
201+
LastUpgradeCheck = 1500;
202202
TargetAttributes = {
203203
0AEC07722A40D4C2003C82E7 = {
204204
CreatedOnToolsVersion = 14.3.1;
@@ -307,6 +307,7 @@
307307
isa = XCBuildConfiguration;
308308
buildSettings = {
309309
ALWAYS_SEARCH_USER_PATHS = NO;
310+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
310311
CLANG_ANALYZER_NONNULL = YES;
311312
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
312313
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -336,9 +337,11 @@
336337
CLANG_WARN_UNREACHABLE_CODE = YES;
337338
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
338339
COPY_PHASE_STRIP = NO;
340+
DEAD_CODE_STRIPPING = YES;
339341
DEBUG_INFORMATION_FORMAT = dwarf;
340342
ENABLE_STRICT_OBJC_MSGSEND = YES;
341343
ENABLE_TESTABILITY = YES;
344+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
342345
GCC_C_LANGUAGE_STANDARD = gnu11;
343346
GCC_DYNAMIC_NO_PIC = NO;
344347
GCC_NO_COMMON_BLOCKS = YES;
@@ -368,6 +371,7 @@
368371
isa = XCBuildConfiguration;
369372
buildSettings = {
370373
ALWAYS_SEARCH_USER_PATHS = NO;
374+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
371375
CLANG_ANALYZER_NONNULL = YES;
372376
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
373377
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -397,9 +401,11 @@
397401
CLANG_WARN_UNREACHABLE_CODE = YES;
398402
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
399403
COPY_PHASE_STRIP = NO;
404+
DEAD_CODE_STRIPPING = YES;
400405
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
401406
ENABLE_NS_ASSERTIONS = NO;
402407
ENABLE_STRICT_OBJC_MSGSEND = YES;
408+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
403409
GCC_C_LANGUAGE_STANDARD = gnu11;
404410
GCC_NO_COMMON_BLOCKS = YES;
405411
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -429,21 +435,22 @@
429435
CODE_SIGN_STYLE = Automatic;
430436
COMBINE_HIDPI_IMAGES = YES;
431437
CURRENT_PROJECT_VERSION = 1;
438+
DEAD_CODE_STRIPPING = YES;
432439
DEVELOPMENT_ASSET_PATHS = "\"hog/Preview Content\"";
433440
DEVELOPMENT_TEAM = SBWA476E6F;
434441
ENABLE_HARDENED_RUNTIME = YES;
435442
ENABLE_PREVIEWS = YES;
436443
GENERATE_INFOPLIST_FILE = YES;
437444
INFOPLIST_FILE = hog/Info.plist;
438-
INFOPLIST_KEY_CFBundleDisplayName = Hog;
445+
INFOPLIST_KEY_CFBundleDisplayName = "Power Hog";
439446
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
440447
INFOPLIST_KEY_LSUIElement = YES;
441448
INFOPLIST_KEY_NSHumanReadableCopyright = "";
442449
LD_RUNPATH_SEARCH_PATHS = (
443450
"$(inherited)",
444451
"@executable_path/../Frameworks",
445452
);
446-
MARKETING_VERSION = 1.1;
453+
MARKETING_VERSION = 0.2;
447454
PRODUCT_BUNDLE_IDENTIFIER = "berlin.green-coding.hog";
448455
PRODUCT_NAME = "$(TARGET_NAME)";
449456
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -462,21 +469,22 @@
462469
CODE_SIGN_STYLE = Automatic;
463470
COMBINE_HIDPI_IMAGES = YES;
464471
CURRENT_PROJECT_VERSION = 1;
472+
DEAD_CODE_STRIPPING = YES;
465473
DEVELOPMENT_ASSET_PATHS = "\"hog/Preview Content\"";
466474
DEVELOPMENT_TEAM = SBWA476E6F;
467475
ENABLE_HARDENED_RUNTIME = YES;
468476
ENABLE_PREVIEWS = YES;
469477
GENERATE_INFOPLIST_FILE = YES;
470478
INFOPLIST_FILE = hog/Info.plist;
471-
INFOPLIST_KEY_CFBundleDisplayName = Hog;
479+
INFOPLIST_KEY_CFBundleDisplayName = "Power Hog";
472480
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
473481
INFOPLIST_KEY_LSUIElement = YES;
474482
INFOPLIST_KEY_NSHumanReadableCopyright = "";
475483
LD_RUNPATH_SEARCH_PATHS = (
476484
"$(inherited)",
477485
"@executable_path/../Frameworks",
478486
);
479-
MARKETING_VERSION = 1.1;
487+
MARKETING_VERSION = 0.2;
480488
PRODUCT_BUNDLE_IDENTIFIER = "berlin.green-coding.hog";
481489
PRODUCT_NAME = "$(TARGET_NAME)";
482490
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -491,6 +499,7 @@
491499
BUNDLE_LOADER = "$(TEST_HOST)";
492500
CODE_SIGN_STYLE = Automatic;
493501
CURRENT_PROJECT_VERSION = 1;
502+
DEAD_CODE_STRIPPING = YES;
494503
DEVELOPMENT_TEAM = SBWA476E6F;
495504
GENERATE_INFOPLIST_FILE = YES;
496505
MACOSX_DEPLOYMENT_TARGET = 13.3;
@@ -510,6 +519,7 @@
510519
BUNDLE_LOADER = "$(TEST_HOST)";
511520
CODE_SIGN_STYLE = Automatic;
512521
CURRENT_PROJECT_VERSION = 1;
522+
DEAD_CODE_STRIPPING = YES;
513523
DEVELOPMENT_TEAM = SBWA476E6F;
514524
GENERATE_INFOPLIST_FILE = YES;
515525
MACOSX_DEPLOYMENT_TARGET = 13.3;
@@ -528,6 +538,7 @@
528538
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
529539
CODE_SIGN_STYLE = Automatic;
530540
CURRENT_PROJECT_VERSION = 1;
541+
DEAD_CODE_STRIPPING = YES;
531542
DEVELOPMENT_TEAM = SBWA476E6F;
532543
GENERATE_INFOPLIST_FILE = YES;
533544
MARKETING_VERSION = 1.0;
@@ -545,6 +556,7 @@
545556
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
546557
CODE_SIGN_STYLE = Automatic;
547558
CURRENT_PROJECT_VERSION = 1;
559+
DEAD_CODE_STRIPPING = YES;
548560
DEVELOPMENT_TEAM = SBWA476E6F;
549561
GENERATE_INFOPLIST_FILE = YES;
550562
MARKETING_VERSION = 1.0;

app/hog/hog.xcodeproj/xcshareddata/xcschemes/hog.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1430"
3+
LastUpgradeVersion = "1500"
44
version = "1.7">
55
<BuildAction
66
parallelizeBuildables = "YES"

0 commit comments

Comments
 (0)