benchmatrix 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ """Public pytest-benchmark matrix and JSON results API."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ from ._schema import MetricName
6
+ from .bench_harness import (
7
+ BenchmarkCase,
8
+ BenchmarkConfig,
9
+ BenchmarkFixture,
10
+ BenchmarkInvocationRecord,
11
+ TargetFunction,
12
+ benchmark_batch_throughput,
13
+ benchmark_single_call_latency,
14
+ benchmark_tail_latency,
15
+ deep_copy,
16
+ make_benchmark_parameters,
17
+ make_benchmark_test,
18
+ run_benchmark_metric,
19
+ shallow_copy,
20
+ )
21
+ from .bench_results import (
22
+ ParsedBenchmarkRow,
23
+ display_benchmark_row,
24
+ display_benchmark_rows,
25
+ load_benchmark_json,
26
+ )
27
+ from .exceptions import BenchmarkJsonError, BenchmatrixError, MetadataSerializationError
28
+
29
+ try:
30
+ __version__ = version("benchmatrix")
31
+ except PackageNotFoundError:
32
+ __version__ = "0.0.0+unknown"
33
+
34
+ __all__ = [
35
+ "__version__",
36
+ "BenchmarkCase",
37
+ "BenchmarkConfig",
38
+ "BenchmarkFixture",
39
+ "BenchmarkInvocationRecord",
40
+ "BenchmarkJsonError",
41
+ "BenchmatrixError",
42
+ "MetadataSerializationError",
43
+ "MetricName",
44
+ "ParsedBenchmarkRow",
45
+ "TargetFunction",
46
+ "benchmark_batch_throughput",
47
+ "benchmark_single_call_latency",
48
+ "benchmark_tail_latency",
49
+ "deep_copy",
50
+ "display_benchmark_row",
51
+ "display_benchmark_rows",
52
+ "load_benchmark_json",
53
+ "make_benchmark_parameters",
54
+ "make_benchmark_test",
55
+ "run_benchmark_metric",
56
+ "shallow_copy",
57
+ ]
benchmatrix/_schema.py ADDED
@@ -0,0 +1,79 @@
1
+ """Private schema for benchmatrix metadata embedded in pytest-benchmark output."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal, TypeAlias
6
+
7
+ MetricName: TypeAlias = Literal[
8
+ "single_call_latency",
9
+ "batch_throughput",
10
+ "tail_latency",
11
+ ]
12
+
13
+ JsonPrimitive: TypeAlias = str | int | float | bool | None
14
+ JsonValue: TypeAlias = JsonPrimitive | list["JsonValue"] | dict[str, "JsonValue"]
15
+
16
+ PRODUCER = "benchmatrix"
17
+ SCHEMA_VERSION = 1
18
+
19
+ METRIC_SINGLE_CALL_LATENCY: MetricName = "single_call_latency"
20
+ METRIC_BATCH_THROUGHPUT: MetricName = "batch_throughput"
21
+ METRIC_TAIL_LATENCY: MetricName = "tail_latency"
22
+
23
+ DEFAULT_METRICS: tuple[MetricName, ...] = (
24
+ METRIC_SINGLE_CALL_LATENCY,
25
+ METRIC_BATCH_THROUGHPUT,
26
+ METRIC_TAIL_LATENCY,
27
+ )
28
+
29
+ KNOWN_METRICS: frozenset[str] = frozenset(DEFAULT_METRICS)
30
+
31
+ KEY_PRODUCER = "benchmatrix_producer"
32
+ KEY_SCHEMA_VERSION = "benchmatrix_schema_version"
33
+ KEY_METRIC_NAME = "metric_name"
34
+ KEY_IMPLEMENTATION_NAME = "implementation_name"
35
+ KEY_CASE_NAME = "case_name"
36
+ KEY_CASE_FRESH_INPUTS = "case_fresh_inputs"
37
+ KEY_WORK_UNITS = "work_units"
38
+ KEY_WORK_UNIT_NAME = "work_unit_name"
39
+ KEY_THROUGHPUT_UNIT = "throughput_unit"
40
+ KEY_TAIL_LATENCY_NOTE = "tail_latency_note"
41
+ KEY_TAIL_PERCENTILES = "tail_percentiles"
42
+
43
+ THROUGHPUT_UNIT_CALLS_PER_SECOND = "calls_per_second"
44
+ THROUGHPUT_UNIT_WORK_UNITS_PER_SECOND = "work_units_per_second"
45
+
46
+ PERCENTILE_50 = 0.50
47
+ PERCENTILE_90 = 0.90
48
+ PERCENTILE_95 = 0.95
49
+ PERCENTILE_99 = 0.99
50
+
51
+ TAIL_PERCENTILES: tuple[float, ...] = (
52
+ PERCENTILE_50,
53
+ PERCENTILE_90,
54
+ PERCENTILE_95,
55
+ PERCENTILE_99,
56
+ )
57
+
58
+ JSON_KEY_BENCHMARKS = "benchmarks"
59
+ JSON_KEY_STATS = "stats"
60
+ JSON_KEY_EXTRA_INFO = "extra_info"
61
+ JSON_KEY_DATA = "data"
62
+ JSON_KEY_NAME = "name"
63
+ JSON_KEY_FULLNAME = "fullname"
64
+
65
+ STAT_MEAN = "mean"
66
+ STAT_MEDIAN = "median"
67
+ STAT_MIN = "min"
68
+
69
+ DERIVED_LATENCY_MEAN = "latency_mean"
70
+ DERIVED_LATENCY_MEDIAN = "latency_median"
71
+ DERIVED_LATENCY_MIN = "latency_min"
72
+ DERIVED_THROUGHPUT_MEAN = "throughput_mean"
73
+ DERIVED_THROUGHPUT_MEDIAN = "throughput_median"
74
+ DERIVED_THROUGHPUT_UNIT_LABEL = "throughput_unit_label"
75
+ DERIVED_P50 = "p50"
76
+ DERIVED_P90 = "p90"
77
+ DERIVED_P95 = "p95"
78
+ DERIVED_P99 = "p99"
79
+ DERIVED_MAX = "max"