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

Function benchmark_add

tests/benchmark_scale.py:210–240  ·  view source on GitHub ↗

Benchmark sorted list add method. Start and limit are an inclusive range of magnitudes. The load of the sorted list is the cube root of the size. Measurements are made by sampling performance at each "moment" of a sorted list while items are added to it. See `init_sorted_list` for

(start, limit, times)

Source from the content-addressed store, hash-verified

208
209
210def benchmark_add(start, limit, times):
211 """Benchmark sorted list add method.
212
213 Start and limit are an inclusive range of magnitudes.
214
215 The load of the sorted list is the cube root of the size.
216
217 Measurements are made by sampling performance at each "moment" of a sorted
218 list while items are added to it. See `init_sorted_list` for how "moment"
219 is used.
220
221 """
222 for exponent in xrange(start, limit + 1):
223 timings = []
224 count = 10 ** exponent
225 sl = sc.SortedList(load=int(count ** (1.0 / 3)))
226
227 for attempt in xrange(times):
228 subtimings = []
229
230 for moment in xrange(10):
231 values = randvalues(count)
232 init_sorted_list(sl, count, moment)
233 gc.collect()
234 subtiming = add(sl, values)
235 subtimings.append(subtiming)
236
237 timing = sum(subtimings)
238 timings.append(timing)
239
240 display('add', timings, count)
241
242
243def benchmark_del(start, limit, times):

Callers

nothing calls this directly

Calls 5

randvaluesFunction · 0.85
displayFunction · 0.85
appendMethod · 0.80
init_sorted_listFunction · 0.70
addFunction · 0.70

Tested by

no test coverage detected