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)
| 208 | |
| 209 | |
| 210 | def 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 | |
| 243 | def benchmark_del(start, limit, times): |
nothing calls this directly
no test coverage detected