bencher.git_info
Git metadata helpers for benchmark time tracking.
Functions
|
Run a git subcommand and return its stripped stdout, or empty string on failure. |
|
Return a time-event label combining wall-clock time and short commit hash. |
Module Contents
- bencher.git_info._run_git(args: list[str], repo_path: str | None = None) str
Run a git subcommand and return its stripped stdout, or empty string on failure.
- bencher.git_info.git_time_event(repo_path: str | None = None) str
Return a time-event label combining wall-clock time and short commit hash.
Example return value:
"2024-06-15 14:59 abc1234"The SHA portion is git’s canonical abbreviated hash (
rev-parse --short), which is typically 7 characters but may be longer in large repositories to avoid ambiguity.Intended to be used with
BenchRunCfg(over_time=True, time_event=...)so the over-time slider shows when and which commit produced the data.Wall-clock time is used instead of commit time so that multiple benchmark runs on the same commit produce distinct labels.
For fork-safety in multithreaded environments (ROS 2, DDS, etc.), call this at module level before starting background threads:
_TIME_EVENT = bn.git_time_event() # safe: no threads yet
Falls back to
"<timestamp> unknown"if not inside a git repository or git is unavailable, keeping the label format consistent.