timeline: make log level calculation a lot faster

This is the step where the timeline graph gets colored with the individual log
level colors. It's roughly 4.5 times faster now. Probably can be made even
better, the code also needs a cleanup.
This commit is contained in:
René Stadler 2012-09-21 22:52:25 +02:00 committed by Stefan Sauer
parent 103700a254
commit 2d508773cc
2 changed files with 21 additions and 2 deletions

View file

@ -129,6 +129,13 @@ class LogModelBase (gtk.GenericTreeModel):
return value
def get_value_range (self, col_id, start, stop):
if col_id != self.COL_LEVEL:
raise NotImplementedError ("XXX FIXME")
return self.line_levels[start:stop]
def on_iter_next (self, line_index):
last_index = len (self.line_offsets) - 1

View file

@ -171,13 +171,26 @@ class LevelDistributionSentinel (object):
if not partitions:
return
level_index = 0
level_iter = None
finished = False
while tree_iter:
y -= 1
if y == 0:
y = YIELD_LIMIT
yield True
level = model_get (tree_iter, id_level)
if level_iter is None:
stop_index = level_index + 512
levels = self.model.get_value_range (id_level,
level_index, stop_index)
level_index = stop_index
level_iter = iter (levels)
try:
level = level_iter.next ()
except StopIteration:
level_iter = None
continue
while i > partitions[partitions_i]:
data.append (tuple (counts))
counts = [0] * MAX_LEVELS
@ -189,7 +202,6 @@ class LevelDistributionSentinel (object):
break
counts[level] += 1
i += 1
tree_iter = model_next (tree_iter)
# Now handle the last one:
data.append (tuple (counts))