Insert-Overlapping PerformanceΒΆ

The tests measure the performance of sets and dicts with integer keys. The following implementation are compared:

The following figure shows the running time of inserting integer intervals one by one into a set and, and finding the intervals overlapping the inserted interval after each insertion, as a function of the number of intervals (see _set_insert_overlapping_intervals.py for the source). It primarily shows the effect of key-type specificication:

_images/IntSetInsertOverlappingAll.png

The faster Banyan implementations here are those which specify the key types, e.g.,

>>> # An integer-interval tree
>>> t = SortedSet(key_type = (int, int), updator = OverlappingIntervalsUpdator)
>>>
>>> # A float-interval tree
>>> t = SortedSet(key_type = (float, float), updator = OverlappingIntervalsUpdator)

following that is the bx implementation, which presumably uses some homogeneous keys internally as well. The slowest Banyan implementation is due to its flexibility: without key-type specification, “intervals” of any type can be used, e.g.,

>>> SortedSet([('a', 'aa'), ('bb', 'mmm')], updator = OverlappingIntervalsUpdator).overlap_point('a')
[('a', 'aa')]

This flexibility comes with a performance penalty.

This Page