plot_utils.py
This file
Path
scripts/plot_utils.py
32 lines · 1.0 KiB · Python
Last changed by
Support hardware counters in plotting scripts (#984)David Peterbefore adoptione262cd6
History of this fileTake it
1"""Shared metric options for the plotting scripts."""23METRICS = {4 "time_wall_clock": ("Time [s]", 1),5 "time_user": ("User CPU time [s]", 1),6 "time_system": ("System CPU time [s]", 1),7 "memory_peak_resident": ("Peak resident memory [MiB]", 1024**2),8 "cpu_cycles": ("CPU cycles", 1),9 "instructions": ("Completed CPU instructions", 1),10 "cache_references": ("Cache references", 1),11 "cache_misses": ("Cache misses", 1),12 "branch_misses": ("Mispredicted branches", 1),13}141516def add_metric_argument(parser):17 parser.add_argument(18 "--metric",19 choices=METRICS,20 default="time_wall_clock",21 help="Metric to plot (default: time_wall_clock). "22 "Times are in seconds; memory is in MiB; hardware counters are unscaled counts.",23 )242526def validate_metric(parser, results, metric):27 for result in results:28 if metric not in result["summary"]:29 parser.error(30 f"metric {metric!r} is unavailable for "31 f"{result.get('name', result['command'])!r}"32 )