From 38d799d4e71364e5b0f7b8496ccb9d3a49c643e8 Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Fri, 7 Nov 2025 11:02:59 +0000 Subject: [PATCH] Add preliminary instructions for energy measurement --- README.md | 27 +++++++++++++++++++++++++++ scripts/energy-stress-and-stop.sh | 8 ++++++++ 2 files changed, 35 insertions(+) create mode 100755 scripts/energy-stress-and-stop.sh diff --git a/README.md b/README.md index e5b91b5..3c2474d 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,33 @@ For each test, you should see output like Latency 9.58ms 6.03ms 94.90ms 85.57% Req/Sec 9936.90 2222.61 10593.00 95.24 ``` + +#### Measuring energy consumption + +You can also measure energy consumption, rather than throughput. +This tooling is still evolving, so the current process is a bit manual and needs several windows. The current tooling requires MacOS or Linux. + +1. Clone the `power-server` utilities, https://github.com/metacosm/power-server. These provide an hardware-independent abstraction layer over hardware power metric tooling. +2. Build with `mvn verify` +3. Change directory to the cli: `cd cli` +4. In the first window, launch the Spring or Quarkus application, wrapped in the power-server application: +```shell +/spring-quarkus-perf-comparison/scripts/infra.sh -s +java -jar target/quarkus-app/quarkus-run.jar -c "java -XX:ActiveProcessorCount=4 -Xms512m -Xmx512m -jar /spring-quarkus-perf-comparison/quarkus3/target/quarkus-app/quarkus-run.jar" +``` +or +```shell +/spring-quarkus-perf-comparison/scripts/infra.sh -s +java -jar target/quarkus-app/quarkus-run.jar -c "java -XX:ActiveProcessorCount=4 -Xms512m -Xmx512m -jar /spring-quarkus-perf-comparison/springboot3/target/springboot3.jar" +``` +5. Meanwhile, open a second window and start the load test. When it's finished it will stop the application, which will terminate the energy measurement: +``` +/spring-quarkus-perf-comparison/scripts/energy-stress-and-stop.sh +``` + +The energy measurement is subject to the same qualifications as normal performance measurement; the processor's thermal regulation may affect results, without tuning the test paramers, on some systems the bottleneck may not be the application, and the timing between starting the application and starting the load test will also affect results. +For more reliable, reproducible, results, these experiments should be done using the more advanced scripts, in a controlled environment. + ### Acceptable: Run on a single machine, with solid automation and detailed output These scripts are being developed. diff --git a/scripts/energy-stress-and-stop.sh b/scripts/energy-stress-and-stop.sh new file mode 100755 index 0000000..7f4f413 --- /dev/null +++ b/scripts/energy-stress-and-stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# This script is useful for measuring energy consumption, in combination with https://github.com/metacosm/power-server + +thisdir=`dirname "$0"` + +jbang wrk2@hyperfoil -t2 -c100 -d20s --rate 2000 --timeout 1s http://localhost:8080/fruits +kill $(lsof -t -i:8080) &>/dev/null +${thisdir}/infra.sh -d