mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
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
29 lines
546 B
Python
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)
|