summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrare/interrupts-graph.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/rare/interrupts-graph.py b/rare/interrupts-graph.py
index c7b824f..1d6fd1f 100755
--- a/rare/interrupts-graph.py
+++ b/rare/interrupts-graph.py
@@ -183,7 +183,7 @@ yvalues = {}
x_count = int(XRANGE / INTERVAL)
# Initialize y values for each name
for name in names:
- ydata = deque([0] * x_count, x_count)
+ ydata = deque([], x_count)
yvalues[name] = ydata
lines = {}
@@ -195,8 +195,7 @@ def update_title():
# Lock to avoid updating the UI while the data is being refreshed
data_lock = threading.Lock()
-# Since yvalues gets filled on the tail, substract from start time
-start_time = -XRANGE
+start_time = 0
@synchronized(data_lock)
def refresh_data():
global start_time
@@ -219,7 +218,9 @@ def update():
ys = yvalues[name]
# Consider only strictly positive values
ydata = [y for y in ys if y > 0]
- xdata = [start_time + i * INTERVAL for i, y in enumerate(ys) if y > 0]
+ # Skip time only if the size of yvalues is bounded
+ skip_time = max(0, start_time - len(ys) * INTERVAL)
+ xdata = [skip_time + i * INTERVAL for i, y in enumerate(ys) if y > 0]
if ydata and is_line_ok(name, ys):
# Data is significant, show it
@@ -270,7 +271,8 @@ def update():
# plt.ylim(ymin, ymin + largest)
plt.ylim(0, largest)
- min_x = max(start_time, 0)
+ # The first XRANGE items fit in the screen
+ min_x = max(start_time - XRANGE, 0)
plt.xlim(min_x, min_x + XRANGE)
def do_draw():