#energy #benchmarking #sustainability

energy-bench

Methods for benchmarking the energy consumption of programs

9 releases

new 0.1.8 May 28, 2024
0.1.7 May 27, 2024

#80 in Profiling

Download history 225/week @ 2024-05-02 30/week @ 2024-05-09 550/week @ 2024-05-16 367/week @ 2024-05-23

1,172 downloads per month

Apache-2.0

30KB
686 lines

Energy Benchmarking Tool (Alpha)

Tool for benchmarking the energy consumption of programs. Idle energy consumption and energy consumed by data generation are not included in the results. A new benchmark builder is created with EnergyTool::new(). A benchmark of function bench_fn with data data_fn can be started with benchmark(bench_fn, data_fn). This function returns a JSON of measurement data.

use energy_bench::EnergyTool;

let builder = EnergyTool::new();

let json = builder.benchmark(bench_fn, data_fn);

Some programs are too short-running to provide accurate energy measurement results. To avoid this, the benchmark can be repeated a fixed number of type between measurements: with_runs_per_measurement. Or it can be repeated until some amount of time has passed: with_min_measurement_duration. By default, benchmarks are run for at least 100ms.

let builder = EnergyTool::new().with_runs_per_measurement(10);

let builder = EnergyTool::new().with_min_measurement_duration(Duration::from_secs(5));

The benchmark results can directly be written to a file:

let file = &File::create("the_file.json")?;
let builder = EnergyTool::new().write_to_file(file);

Idle consumption is always computed beforehand, and is subtracted from the results. The default duration is one minute, however it can be increased with:

let builder = EnergyTool::new().with_idle_duration(Duration::from_secs(90));

Features

We support multiple measuring devices.

Currently, we support the features rapl and ina.

For AMD users, RAPL can be read by adding the amd flag.

Dependencies

~1.2–1.8MB
~37K SLoC