mirror of
https://github.com/aziascreations/PB-MessagePack.git
synced 2026-11-24 18:28:44 +01:00
Added examples, Added performance tests, Updated readme
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# Shared by the Python performance tests, see `_PerfTesting.pbi` for the output format.
|
||||
import statistics
|
||||
import time
|
||||
|
||||
RUNS = 5
|
||||
|
||||
|
||||
def run(scenario, operations, function):
|
||||
"""Runs `function` once to warm up, then `RUNS` times, and prints its median."""
|
||||
check = function()
|
||||
times = []
|
||||
for _ in range(RUNS):
|
||||
start = time.perf_counter()
|
||||
check = function()
|
||||
times.append((time.perf_counter() - start) * 1000)
|
||||
median = statistics.median(times)
|
||||
print(f"python,{scenario},{median:.1f},{median * 1_000_000 / operations:.1f},{check}", flush=True)
|
||||
Reference in New Issue
Block a user