bundle.perf_report.report.base

Shared utilities for performance report generation (cProfile and Tracy).

Attributes

Functions

format_time_seconds(→ tuple[str, str])

Format a seconds value into a human-readable (value, unit) pair.

format_time_ns(→ tuple[str, str])

Format a nanosecond value into a human-readable (value, unit) pair.

format_delta(→ str)

delta_color(→ str)

best_unit_for_values_seconds(→ tuple[str, float])

Return the best (unit, multiplier_from_seconds) for a list of second values.

best_unit_for_values_ns(→ tuple[str, float])

Return the best (unit, multiplier_from_ns) for a list of nanosecond values.

shorten_path(→ str)

Truncate a file path to its last max_parts segments.

normalize_src_path(→ str)

Extract bundle-relative path: .../bundle/core/tracer.py -> core/tracer.py

safe_key(→ str)

get_platform_id(→ str)

get_platform_meta(→ dict)

truncate_labels(→ list[str])

setup_plot(→ tuple[matplotlib.pyplot.Figure, ...)

Create a dark-themed horizontal bar chart canvas.

draw_baseline_bars(ax, y_pos, baseline_times, bar_height)

Draw baseline comparison bars and add the legend.

finalize_plot(→ pathlib.Path)

Apply bar-value labels, axis formatting, and save the plot.

build_platform_section(→ bundle.latex.Section)

Build a platform info summary table from HDF5 metadata.

find_baseline_version(→ str | None)

Find the most recent version in HDF5 that isn't the current one and has this platform.

generate_report(input_path, output_path, h5_path, *, ...)

Generic report generation pipeline shared by cProfile and Tracy backends.

Module Contents

bundle.perf_report.report.base.LOGGER
bundle.perf_report.report.base.MAX_PARALLEL_ASYNC = 20
bundle.perf_report.report.base.TOP_N_PLOT = 10
bundle.perf_report.report.base.TOP_N_TABLE = 30
bundle.perf_report.report.base.TIME_THRESHOLDS = [(1.0, 's', 1.0), (0.001, 'ms', 1000.0), (1e-06, 'μs', 1000000.0), (0.0, 'ns', 1000000000.0)]
bundle.perf_report.report.base.CLR_CURRENT = '#87CEEB'
bundle.perf_report.report.base.CLR_BASELINE = '#FF8C66'
bundle.perf_report.report.base.format_time_seconds(seconds: float) tuple[str, str]

Format a seconds value into a human-readable (value, unit) pair.

bundle.perf_report.report.base.format_time_ns(nanoseconds: int | float) tuple[str, str]

Format a nanosecond value into a human-readable (value, unit) pair.

bundle.perf_report.report.base.format_delta(current: int | float, baseline: int | float) str
bundle.perf_report.report.base.delta_color(current: int | float, baseline: int | float) str
bundle.perf_report.report.base.best_unit_for_values_seconds(times_seconds: list[float]) tuple[str, float]

Return the best (unit, multiplier_from_seconds) for a list of second values.

bundle.perf_report.report.base.best_unit_for_values_ns(times_ns: list[int | float]) tuple[str, float]

Return the best (unit, multiplier_from_ns) for a list of nanosecond values.

bundle.perf_report.report.base.shorten_path(file_path: str, max_parts: int = 2) str

Truncate a file path to its last max_parts segments.

bundle.perf_report.report.base.normalize_src_path(src_file: str) str

Extract bundle-relative path: …/bundle/core/tracer.py -> core/tracer.py

bundle.perf_report.report.base.safe_key(v: str) str
bundle.perf_report.report.base.get_platform_id() str
bundle.perf_report.report.base.get_platform_meta() dict
bundle.perf_report.report.base.truncate_labels(labels: list[str], max_len: int = 50) list[str]
bundle.perf_report.report.base.setup_plot(n_bars: int, has_baseline: bool) tuple[matplotlib.pyplot.Figure, matplotlib.pyplot.Axes, numpy.ndarray]

Create a dark-themed horizontal bar chart canvas.

bundle.perf_report.report.base.draw_baseline_bars(ax: matplotlib.pyplot.Axes, y_pos: numpy.ndarray, baseline_times: list[float], bar_height: float)

Draw baseline comparison bars and add the legend.

bundle.perf_report.report.base.finalize_plot(fig: matplotlib.pyplot.Figure, ax: matplotlib.pyplot.Axes, bars: Any, max_val: float, xlabel: str, plot_path: pathlib.Path) pathlib.Path

Apply bar-value labels, axis formatting, and save the plot.

bundle.perf_report.report.base.build_platform_section(meta: dict) bundle.latex.Section

Build a platform info summary table from HDF5 metadata.

bundle.perf_report.report.base.find_baseline_version(storage: Any, current_version: str, platform_id: str) str | None

Find the most recent version in HDF5 that isn’t the current one and has this platform.

async bundle.perf_report.report.base.generate_report(input_path: pathlib.Path, output_path: pathlib.Path, h5_path: pathlib.Path | None, *, extractor_cls: Any, storage_cls: Any, generate_plot_fn: Callable, build_section_fn: Callable, build_func_map_fn: Callable, file_type_label: str)

Generic report generation pipeline shared by cProfile and Tracy backends.