Skip to content
Myr

plot_utils.py

This file

Path

scripts/plot_utils.py

27 lines · 801 bytes · Python

Last changed by

Support all exported metrics in plotting scripts (#981)David Peterbefore adoptionef86c83

History of this file

Take 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}91011def add_metric_argument(parser):12    parser.add_argument(13        "--metric",14        choices=METRICS,15        default="time_wall_clock",16        help="Metric to plot (default: time_wall_clock). "17        "Times are in seconds; memory is in MiB.",18    )192021def validate_metric(parser, results, metric):22    for result in results:23        if metric not in result["summary"]:24            parser.error(25                f"metric {metric!r} is unavailable for "26                f"{result.get('name', result['command'])!r}"27            )