mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +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
34 lines
841 B
Python
34 lines
841 B
Python
# Adapted from python/pyperformance 1.14.0 (pickle_pure_python).
|
|
|
|
import datetime
|
|
import pickle
|
|
|
|
|
|
profile = {
|
|
"age": 18,
|
|
"birthday": datetime.date(1980, 5, 7),
|
|
"country": "BR",
|
|
"encrypted_id": "G9urXXAJwjE",
|
|
"flags": 412317970704,
|
|
"friend_count": 0,
|
|
"locale_preference": "pt_BR",
|
|
"tags": ["a", "b", "c", "d", "e", "f", "g"],
|
|
"username": "collinwinter",
|
|
}
|
|
record = ([*range(20)], 60)
|
|
group = [dict(profile, id=index) for index in range(3)]
|
|
list_data = [[list(range(10)), list(range(10))] for _ in range(10)]
|
|
dict_data = {key: dict.fromkeys(range(10)) for key in range(100)}
|
|
protocol = pickle.HIGHEST_PROTOCOL
|
|
dumps = pickle._dumps
|
|
|
|
for obj, count in (
|
|
(profile, 20),
|
|
(record, 20),
|
|
(group, 20),
|
|
(list_data, 10),
|
|
(dict_data, 5),
|
|
):
|
|
for _ in range(count):
|
|
dumps(obj, protocol)
|