wattameter.benchmark package

wattameter.benchmark.overhead module

Overhead of using WattAMeter

wattameter.benchmark.overhead.benchmark_dynamic_overhead(cpu_stress_test=False, gpu_burn_dir=None)

Call main() and let it run for a short time to measure dynamic overhead

  • Use a frequency of 10 Hz for writing data to disk

  • Use a temporary directory to avoid writing files to the current directory

  • Let it run for 10 seconds, then send a SIGINT to terminate

  • Mock the cli arguments to set dt_read to 0.1 seconds

Parameters:
  • cpu_stress_test – If True, stress the CPU during the benchmark (default: False)

  • gpu_burn_dir – If not None, path to the gpu_burn benchmark (default: None)

wattameter.benchmark.overhead.benchmark_static_overhead()

Call main() and exit as soon as BaseTracker::track_until_forced_exit is reached

  • Use mock to replace BaseTracker::track_until_forced_exit with a function that just returns

  • Use a temporary directory to avoid writing files to the current directory

Returns:

static overhead in seconds

wattameter.benchmark.overhead.run_benchmark()

wattameter.benchmark.update_time module

Frequency of Update Benchmark Script for WattAMeter

This script measures the frequency of updates for different metrics. Since update frequency measurements are machine-dependent, this script is provided as an example rather than as a test.

Usage:

python update_time.py

wattameter.benchmark.update_time.benchmark_pynvml_update_time(gpu_burn_dir=None)

Benchmarks the update time of pynvml nvmlDeviceGetPowerUsage function using estimate_dt().

wattameter.benchmark.update_time.benchmark_rapl_update_time()

Benchmarks the update time of the RAPL files using estimate_dt().

wattameter.benchmark.update_time.run_benchmark()

wattameter.benchmark.utils module

Utility functions for the benchmarks

wattameter.benchmark.utils.compile_gpu_burn(gpu_burn_dir)

Compiles the gpu_burn benchmark and returns the path to the executable.

Parameters:

gpu_burn_dir – Path to the gpu_burn benchmark directory.

Returns:

Path to the compiled gpu_burn executable.

wattameter.benchmark.utils.estimate_dt(f, n_trials: int = 10, sleep_dt: float = 0.0001, ntmax: int = 1000) list[float]

Estimates the average time interval between changes in the output of a given function.

The function assumes that the value retrieved by f changes periodically and uses this change to estimate the time interval.

Parameters:
  • f – A function that retrieves the current value to monitor for changes.

  • n_trials (int) – The number of trials to average the time interval over (default is 10). (default: 10)

  • sleep_dt (float) – The sleep duration between checks for value updates in seconds (default is 0.0001). (default: 0.0001)

  • ntmax (int) – The maximum number of sleep iterations to wait for a value update (default is 1000). (default: 1000)

Return type:

list[float]

Returns:

The estimated average time interval in seconds.

Raises:

RuntimeError – If the value does not change within the maximum wait time.

wattameter.benchmark.utils.get_cpu_info()

Get basic CPU information.

Source - https://stackoverflow.com/a/13078519 Posted by dbn, modified by community. See post ‘Timeline’ for change history Retrieved 2025-12-03, License - CC BY-SA 4.0

wattameter.benchmark.utils.print_system_info()

Print basic system information that might affect overhead.

wattameter.benchmark.utils.stress_cpu(n: int = 9999)

Function to stress the CPU by performing large matrix multiplications.

https://www.reddit.com/r/overclocking/comments/1ckvr0w/comment/l2psl0j/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

Parameters:

n (int) – Number of matrix multiplications to perform. (default: 9999)