wattameter.benchmark package

wattameter.benchmark.overhead module

Overhead of using WattAMeter

wattameter.benchmark.overhead.benchmark_dynamic_overhead(cpu_stress_test=False, gpu_burn_path=None, n: int = 0)

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_path – If not None, path to the gpu_burn executable (default: None)

  • n (int) – Size of the square matrices to multiply for CPU stress test (ignored if cpu_stress_test is False). Set to 0 to use the default size. (default: 0)

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_path=None, n_trials=100)

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

Parameters:
  • gpu_burn_path – If not None, path to the gpu_burn executable (default: None)

  • n_trials – Number of trials to perform for estimating update time (default: 100)

wattameter.benchmark.update_time.benchmark_rapl_update_time(cpu_stress_test=False, n_trials=100, n: int = 0)

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

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

  • n_trials – Number of trials to perform for estimating update time (default: 100)

  • n (int) – Size of the square matrices to multiply for CPU stress test (ignored if cpu_stress_test is False). Set to 0 to use the default size. (default: 0)

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 = 100000) 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 100000). (default: 100000)

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_benchmark_banner(title: str)

Print a standardized benchmark section banner.

Print a standardized benchmark completion footer.

wattameter.benchmark.utils.print_system_info()

Print basic system information that might affect overhead.

wattameter.benchmark.utils.start_cpu_stress(warmup_s: float = 5.0, n: int = 0)

Start the CPU stress process and return it, or None if startup fails.

Parameters:
  • warmup_s (float) – Time in seconds to wait after starting the CPU stress before returning (default: 5.0)

  • n (int) – Size of the square matrices to multiply. (default: 0)

Returns:

The multiprocessing.Process object for the CPU stress process, or None if not started

wattameter.benchmark.utils.start_gpu_burn(gpu_burn_path, warmup_s: float = 0.0)

Optionally compile and start gpu_burn, returning the spawned process or None.

Parameters:
  • gpu_burn_path – Path to gpu_burn executable, or None to skip starting gpu_burn

  • warmup_s (float) – Time in seconds to wait after starting gpu_burn before returning (default: 0.0)

Returns:

The subprocess.Popen object for the gpu_burn process, or None if not started

wattameter.benchmark.utils.stop_cpu_stress(cpu_stress_process)

Terminate the CPU stress process if it was started.

Parameters:

cpu_stress_process – The multiprocessing.Process object for the CPU stress process, or None if not started

wattameter.benchmark.utils.stop_gpu_burn(gpu_burn_process)

Terminate gpu_burn if it was started.

Parameters:

gpu_burn_process – The subprocess.Popen object for the gpu_burn process, or None if not started

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

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) – Size of the square matrices to multiply. (default: 8192)