Files
Lee Dogeon 99a63f92aa benchmarks: add pyperformance workloads (#8633)
Add dependency-free CPU-bound workloads adapted from pyperformance 1.14.0 to cover interpreter, standard-library serialization, regex, numeric, and garbage-collection paths under the existing Criterion and CodSpeed harnesses. Keep inputs deterministic and scale expensive cases for simulation while checking that benchmark execution does not leak interpreter state.

Assisted-by: Codex:gpt-5.6-sol
2026-09-01 10:03:29 +09:00

29 lines
546 B
Python

# Adapted from python/pyperformance 1.14.0 (json_dumps).
import json
empty = ({}, 2000)
simple_data = {
"key1": 0,
"key2": True,
"key3": "value",
"key4": "foo",
"key5": "string",
}
simple = (simple_data, 1000)
nested_data = {
"key1": 0,
"key2": simple_data,
"key3": "value",
"key4": simple_data,
"key5": simple_data,
"key": "ąćż",
}
nested = (nested_data, 1000)
huge = ([nested_data] * 1000, 1)
for obj, count in (empty, simple, nested, huge):
for _ in range(count):
json.dumps(obj)