Skip to content

Commit

Permalink
Merge pull request #38 from msg-systems/deinerj/issue37
Browse files Browse the repository at this point in the history
Deinerj/issue37
  • Loading branch information
deinerj authored Oct 18, 2023
2 parents a75b9d7 + 7c57ca9 commit fb3063c
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 243 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- no infinite loop on misconfigured csv delimiter,
- fix NaN on first measurements with zero duration.
- upgrade dependencies
- replace discontinued Open Hardware Monitor by fork Libre Hardware Monitor

## 2023-03-07
- refactoring and release 1.0.0
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ The CPU usage of the program and the current power consumption are aggregated to
The result of the measurement is the energy consumption in watt hours or joule.

### Prerequisites
- Tool Open Hardware Monitor is installed: https://openhardwaremonitor.org/downloads/
- Open Hardware Monitor is configured to start a web server:
![Webserver aktivieren](docs/omh-webserver.png)
- Tool Libre Hardware Monitor is installed: https://github.com/LibreHardwareMonitor/LibreHardwareMonitor
- Libre Hardware Monitor is configured to start a web server:
![Webserver aktivieren](docs/lhm-webserver.png)
- If necessary, an alternative port (default is 8085) can be also activated there.
- __IMPORTANT: To start the web server, Open Hardware Monitor may have to be started as administrator.__
- __IMPORTANT: To start the web server, Libre Hardware Monitor may have to be started as administrator.__
- After that the tool is also accessible in the browser: http://localhost:8085/.
- The JUnit extension internally reads the json document, which can be retrieved at http://localhost:8085/data.json.
- __To start the Java agent, the "fat jar" (incl. dependencies) first must be built using the Gradle task "shadowJar"__.
- __Copy "src/main/resources/jpowermonitor-template.yaml" to the execution directory and rename to "./jpowermonitor.yaml"__.
- __Configure (at least) openHardwareMonitor.paths.path to fit your machine__.
- __Configure (at least) measurement -> lhm -> paths -> path to fit your machine__.
- Tool HWiNFO could be used alternatively, __measurement -> method__ must be set to 'csv' and Logging to CSV in HWiNFO must be active: https://www.hwinfo.com/

### Java Agent
- For testing call with `java -javaagent:.\build\libs\jpowermonitor-0.1.0-SNAPSHOT-all.jar[=path-to-jpowermonitor.yaml] -jar .\build\libs\jpowermonitor-0.1.0-SNAPSHOT-all.jar [runtimeSeconds] [cpuThreads]`
- .\build\libs\jpowermonitor-0.1.0-SNAPSHOT-all.jar is just an example and can be replaced by any *.jar of your choice
- For testing call with `java -javaagent:.\build\libs\jpowermonitor-1.0.2-SNAPSHOT-all.jar[=path-to-jpowermonitor.yaml] -jar .\build\libs\jpowermonitor-1.0.2-SNAPSHOT-all.jar [runtimeSeconds] [cpuThreads]`
- .\build\libs\jpowermonitor-1.0.2-SNAPSHOT-all.jar is just an example and can be replaced by any *.jar of your choice
- For starting the agent with Spring Boot, Servlet-Container etc. please consult the respective documentation for adding a java agent.

### Limitations
Expand All @@ -47,7 +47,7 @@ For the configuration of the JUnit extension a yaml file with the name of the ex
| percentageOfSamplesAtBeginningToDiscard | What percentage of samples should be discarded at the beginning of the measurement to get more meaningful results. Meaningful: 5-20%. <br/>_(Parameter is only used in JUnitExtension, not in JavaAgent)_ | X | 15 |
| samplingIntervalInMs | Polling interval for test phase. <br/>_(Parameter is only used in JUnitExtension, not in JavaAgent)_ | X | 300 |
| carbonDioxideEmissionFactor | Conversion factor to calculate approximated CO2 consumption in grams from energy consumption per kWh. Depends on the energy mix of your location, for germany compare e. g. https://www.umweltbundesamt.de/themen/klima-energie/energieversorgung/strom-waermeversorgung-in-zahlen#Strommix | X | 485 |
| measurement -> method | Specify which measurement method to use. Possible values: ohm, csv | | 'ohm' |
| measurement -> method | Specify which measurement method to use. Possible values: lhm, csv | | 'lhm' |
| measurement -> csv | | X | Configuration for reading from csv file. E.g. output from HWInfo |
| measurement -> csv -> inputFile | Path to csv file to read measure values from | | 'hwinfo.csv' |
| measurement -> csv -> lineToRead | Which line in the csv input file contains the current measured values? The first or the last? This depends on the measurement tool. Possible value: first, last | X | 'last' |
Expand All @@ -57,11 +57,11 @@ For the configuration of the JUnit extension a yaml file with the name of the ex
| measurement -> csv -> columns -> energyInIdleMode | For the current measuring sensors the base load per sensor path can be configured (self-measured). If nothing is specified, then a base load measurement is performed in `@BeforeAll` (see also initCycles and samplingIntervalForInitInMs) and this value is used. | X | |
| measurement -> csv -> encoding | Encoding to use for reading the csv input file | X | 'UTF-8' |
| measurement -> csv -> delimiter | Delimiter to use for separating the columns in the csv input file | X | ',' |
| measurement -> ohm | | X | Configuration for reading from open hardware monitor |
| measurement -> ohm -> url | (** started in administrator mode **) | | Url of the Open Hardware Monitor incl. port |
| measurement -> ohm -> paths | | | Multiple paths to the sensors can be specified. This depends on the machine and must be viewed in the Open Hardware Monitor. |
| measurement -> ohm -> paths -> path | | | Path to a sensor |
| measurement -> ohm -> paths -> energyInIdleMode | For the current measuring sensors the base load per sensor path can be configured (self-measured). If nothing is specified, then a base load measurement is performed in `@BeforeAll` (see also initCycles and samplingIntervalForInitInMs) and this value is used. | X | |
| measurement -> lhm | | X | Configuration for reading from Libre Libre Hardware Monitor |
| measurement -> lhm -> url | (** started in administrator mode **) | | Url of the Libre Hardware Monitor incl. port |
| measurement -> lhm -> paths | | | Multiple paths to the sensors can be specified. This depends on the machine and must be viewed in the Libre Hardware Monitor. |
| measurement -> lhm -> paths -> path | | | Path to a sensor |
| measurement -> lhm -> paths -> energyInIdleMode | For the current measuring sensors the base load per sensor path can be configured (self-measured). If nothing is specified, then a base load measurement is performed in `@BeforeAll` (see also initCycles and samplingIntervalForInitInMs) and this value is used. | X | |
| csvRecording -> resultCsv | | X | Result CSV Name (specify paths with slash, they will be created automatically) |
| csvRecording -> measurementCsv | Measurement CSV Name (specify paths with slash, they will be created automatically) | X | |
| javaAgent -> packageFilter | Filter power and energy for methods starting with this packageFilter names, write results of filtered methods to separate CSV files. | X | 'group.msg', de.gillardon' |
Expand All @@ -78,7 +78,7 @@ You may build the jpowermonitor fat jar using the build target `shadowJar` and t

The add the test dependency to your gradle build (analogue for maven builds):
```
testImplementation files('libs/jpowermonitor-1.0.1-all.jar')
testImplementation files('libs/jpowermonitor-1.0.2-all.jar')
```

Alternatively you call the build target `publishLocal` in the jPowerMonitor project and publish the jar to your local maven repository.
Expand Down
Loading

0 comments on commit fb3063c

Please sign in to comment.