(test, name, ctor, setup, func_name, limit)
| 26 | return (end - start) |
| 27 | |
| 28 | def 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 | |
| 63 | def register_test(func): |
| 64 | tests[getattr(func, name_attr)] = func |
no test coverage detected