MCPcopy
hub / github.com/grantjenks/python-sortedcontainers / benchmark

Function benchmark

tests/benchmark.py:28–61  ·  view source on GitHub ↗
(test, name, ctor, setup, func_name, limit)

Source from the content-addressed store, hash-verified

26 return (end - start)
27
28def benchmark(test, name, ctor, setup, func_name, limit):
29 if args.load > 0:
30 load = args.load
31 ctor_original = ctor
32 def ctor_load():
33 obj = ctor_original()
34 obj._reset(load)
35 return obj
36 ctor = ctor_load
37
38 for size in sizes:
39 if not args.no_limit and size > limit:
40 continue
41
42 # warmup
43
44 obj = ctor()
45 setup(obj, size)
46 func = getattr(obj, func_name)
47 measure(test, func, size)
48
49 # record
50
51 times = []
52
53 for rpt in range(5):
54 obj = ctor()
55 setup(obj, size)
56 func = getattr(obj, func_name)
57 times.append(measure(test, func, size))
58
59 times.sort()
60 print(getattr(test, name_attr), name + args.suffix, size, times[0],
61 times[-1], times[2], sum(times) / len(times))
62
63def register_test(func):
64 tests[getattr(func, name_attr)] = func

Callers 2

benchmark_scale.pyFile · 0.85
mainFunction · 0.85

Calls 2

measureFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected