#energy #benchmarking #sustainability

bin+lib energy-bench

Methods for benchmarking the energy consumption of programs

31 releases

new 0.1.30 Dec 9, 2024
0.1.29 Nov 22, 2024
0.1.21 Oct 31, 2024
0.1.17 Sep 10, 2024
0.1.8 May 28, 2024

#102 in Profiling

Download history 615/week @ 2024-09-09 118/week @ 2024-09-16 41/week @ 2024-09-23 16/week @ 2024-09-30 5/week @ 2024-10-07 133/week @ 2024-10-14 171/week @ 2024-10-21 265/week @ 2024-10-28 272/week @ 2024-11-04 18/week @ 2024-11-11 767/week @ 2024-11-18 54/week @ 2024-11-25

1,121 downloads per month

Apache-2.0

24KB
472 lines

Energy Benchmarking Tool

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 EnergyBenchBuilder::new(). A benchmark of function bench_fn with data data_fn can be started with benchmark(name, data_fn, bench_fn). This function returns a JSON of measurement data.

Check out the energy-benchmarking-example project for a minimal example.

use energy_bench::EnergyTool;

let bench = EnergyBenchBuilder::new("benchmark name").build();

bench.benchmark("instance name", data_fn, bench_fn);

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

let bench = EnergyBenchBuilder::new("benchmark name")
    .with_min_measurement_duration(Duration::from_secs(2))
    .build();

Dependencies

~4–13MB
~138K SLoC