MCPcopy Index your code
hub / github.com/grantjenks/python-sortedcontainers / main

Function main

tests/benchmark.py:97–144  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

95args = parser.parse_args()
96
97def main(name):
98 global sizes, lists
99
100 detail('Benchmarking:', name)
101
102 detail('Seed:', args.seed)
103 random.seed(args.seed)
104
105 sizes.extend(args.size or [100, 1000, 10000, 100000, 1000000, 10000000])
106
107 detail('Sizes:', sizes)
108
109 lists.update((key, list(range(key))) for key in sizes)
110 for key in sizes:
111 random.shuffle(lists[key])
112
113 test_names = args.test or tests.keys()
114 kind_names = args.kind or kinds.keys()
115
116 detail('Tests:', list(test_names))
117 detail('Kinds:', list(kind_names))
118
119 detail('test_name', 'data_type', 'size', 'min', 'max', 'median', 'mean')
120
121 for test in impls:
122 if test not in test_names:
123 continue
124 for name in impls[test]:
125 if name not in kind_names:
126 continue
127 details = impls[test][name]
128 try:
129 benchmark(
130 tests[test],
131 name,
132 details['ctor'],
133 details['setup'],
134 details['func'],
135 details['limit'],
136 )
137 except Exception:
138 logging.exception('Benchmark Error')
139 logging.error('Test: %s', test)
140 logging.error('Name: %s', name)
141 for key in sorted(details):
142 logging.error('Details[%r]: %s', key, details[key])
143
144 detail('Benchmark Stop')

Calls 5

detailFunction · 0.85
benchmarkFunction · 0.85
extendMethod · 0.80
keysMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected