Benchmark sorted list delitem method. Start and limit are an inclusive range of magnitudes. The load of the sorted list is the square root of the size. Measurements are made by sampling performance at each "moment" of a sorted list while items are deleted from it. See `init_sorted
(start, limit, times)
| 241 | |
| 242 | |
| 243 | def benchmark_del(start, limit, times): |
| 244 | """Benchmark sorted list delitem method. |
| 245 | |
| 246 | Start and limit are an inclusive range of magnitudes. |
| 247 | |
| 248 | The load of the sorted list is the square root of the size. |
| 249 | |
| 250 | Measurements are made by sampling performance at each "moment" of a sorted |
| 251 | list while items are deleted from it. See `init_sorted_list` for how |
| 252 | "moment" is used. |
| 253 | |
| 254 | """ |
| 255 | for exponent in xrange(start, limit + 1): |
| 256 | timings = [] |
| 257 | count = 10 ** exponent |
| 258 | sl = sc.SortedList(load=int(count ** (1.0 / 3))) # 2))) |
| 259 | |
| 260 | for attempt in xrange(times): |
| 261 | subtimings = [] |
| 262 | |
| 263 | for moment in xrange(-5, 0): |
| 264 | indices = randindices(count) |
| 265 | init_sorted_list(sl, count, moment) |
| 266 | gc.collect() |
| 267 | subtiming = delitem(sl, indices) |
| 268 | subtimings.append(subtiming) |
| 269 | |
| 270 | timing = sum(subtimings) |
| 271 | timings.append(timing) |
| 272 | |
| 273 | display('del', timings, count) |
| 274 | |
| 275 | |
| 276 | def display(name, times, size, last=['', 0]): |
nothing calls this directly
no test coverage detected