Added examples, Added performance tests, Updated readme

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-11-03 16:51:37 +01:00
parent 3d259d363a
commit 9facb66ee8
44 changed files with 3295 additions and 32 deletions
+37
View File
@@ -0,0 +1,37 @@
# Writes and reads the workload shared with the PureBasic tests, see `_Workload.pbi`.
# The maps are packed from and unpacked to dicts, how they're usually handled in Python.
import sys
from pathlib import Path
import msgpack
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from _PerfTesting import run
MAPS = 100_000
MAP = {f"Key{i:02}": i for i in range(16)}
def write():
packer = msgpack.Packer(autoreset=False)
pack = packer.pack
for _ in range(MAPS):
pack(MAP)
return packer.bytes()
def read():
unpacker = msgpack.Unpacker(raw=False)
unpacker.feed(ENCODED)
unpack = unpacker.unpack
total = 0
for _ in range(MAPS):
for key, value in unpack().items():
total += len(key) + value
return total
ENCODED = write()
run("write", MAPS, lambda: len(write()))
run("read", MAPS, read)