]> code.ossystems Code Review - openembedded-core.git/commitdiff
pybootchartgui/draw.py: skip empty CPU and disk usage charts
authorPatrick Ohly <patrick.ohly@intel.com>
Wed, 30 Nov 2016 09:50:05 +0000 (10:50 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 7 Dec 2016 10:36:10 +0000 (10:36 +0000)
The only real change is the addition of two if checks that skips the
corresponding drawing code when there is no data.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/pybootchartgui/pybootchartgui/draw.py

index bddd8048c9ab070ae22f67f656d766dbbc539224..ec5dd333a1229be5307075eed041ed349b8a7d06 100644 (file)
@@ -344,56 +344,58 @@ def render_charts(ctx, options, clip, trace, curr_y, w, h, sec_w):
        proc_tree = options.proc_tree(trace)
 
        # render bar legend
-       ctx.set_font_size(LEGEND_FONT_SIZE)
-
-       draw_legend_box(ctx, "CPU (user+sys)", CPU_COLOR, off_x, curr_y+20, leg_s)
-       draw_legend_box(ctx, "I/O (wait)", IO_COLOR, off_x + 120, curr_y+20, leg_s)
-
-       # render I/O wait
-       chart_rect = (off_x, curr_y+30, w, bar_h)
-       if clip_visible (clip, chart_rect):
-               draw_box_ticks (ctx, chart_rect, sec_w)
-               draw_annotations (ctx, proc_tree, trace.times, chart_rect)
-               draw_chart (ctx, IO_COLOR, True, chart_rect, \
-                           [(sample.time, sample.user + sample.sys + sample.io) for sample in trace.cpu_stats], \
-                           proc_tree, None)
-               # render CPU load
-               draw_chart (ctx, CPU_COLOR, True, chart_rect, \
-                           [(sample.time, sample.user + sample.sys) for sample in trace.cpu_stats], \
-                           proc_tree, None)
-
-       curr_y = curr_y + 30 + bar_h
+       if trace.cpu_stats:
+               ctx.set_font_size(LEGEND_FONT_SIZE)
+
+               draw_legend_box(ctx, "CPU (user+sys)", CPU_COLOR, off_x, curr_y+20, leg_s)
+               draw_legend_box(ctx, "I/O (wait)", IO_COLOR, off_x + 120, curr_y+20, leg_s)
+
+               # render I/O wait
+               chart_rect = (off_x, curr_y+30, w, bar_h)
+               if clip_visible (clip, chart_rect):
+                       draw_box_ticks (ctx, chart_rect, sec_w)
+                       draw_annotations (ctx, proc_tree, trace.times, chart_rect)
+                       draw_chart (ctx, IO_COLOR, True, chart_rect, \
+                                   [(sample.time, sample.user + sample.sys + sample.io) for sample in trace.cpu_stats], \
+                                   proc_tree, None)
+                       # render CPU load
+                       draw_chart (ctx, CPU_COLOR, True, chart_rect, \
+                                   [(sample.time, sample.user + sample.sys) for sample in trace.cpu_stats], \
+                                   proc_tree, None)
+
+               curr_y = curr_y + 30 + bar_h
 
        # render second chart
-       draw_legend_line(ctx, "Disk throughput", DISK_TPUT_COLOR, off_x, curr_y+20, leg_s)
-       draw_legend_box(ctx, "Disk utilization", IO_COLOR, off_x + 120, curr_y+20, leg_s)
-
-        # render I/O utilization
-       chart_rect = (off_x, curr_y+30, w, bar_h)
-       if clip_visible (clip, chart_rect):
-               draw_box_ticks (ctx, chart_rect, sec_w)
-               draw_annotations (ctx, proc_tree, trace.times, chart_rect)
-               draw_chart (ctx, IO_COLOR, True, chart_rect, \
-                           [(sample.time, sample.util) for sample in trace.disk_stats], \
-                           proc_tree, None)
-
-       # render disk throughput
-       max_sample = max (trace.disk_stats, key = lambda s: s.tput)
-       if clip_visible (clip, chart_rect):
-               draw_chart (ctx, DISK_TPUT_COLOR, False, chart_rect, \
-                           [(sample.time, sample.tput) for sample in trace.disk_stats], \
-                           proc_tree, None)
-
-       pos_x = off_x + ((max_sample.time - proc_tree.start_time) * w / proc_tree.duration)
-
-       shift_x, shift_y = -20, 20
-       if (pos_x < off_x + 245):
-               shift_x, shift_y = 5, 40
-
-       label = "%dMB/s" % round ((max_sample.tput) / 1024.0)
-       draw_text (ctx, label, DISK_TPUT_COLOR, pos_x + shift_x, curr_y + shift_y)
-
-       curr_y = curr_y + 30 + bar_h
+       if trace.disk_stats:
+               draw_legend_line(ctx, "Disk throughput", DISK_TPUT_COLOR, off_x, curr_y+20, leg_s)
+               draw_legend_box(ctx, "Disk utilization", IO_COLOR, off_x + 120, curr_y+20, leg_s)
+
+               # render I/O utilization
+               chart_rect = (off_x, curr_y+30, w, bar_h)
+               if clip_visible (clip, chart_rect):
+                       draw_box_ticks (ctx, chart_rect, sec_w)
+                       draw_annotations (ctx, proc_tree, trace.times, chart_rect)
+                       draw_chart (ctx, IO_COLOR, True, chart_rect, \
+                                   [(sample.time, sample.util) for sample in trace.disk_stats], \
+                                   proc_tree, None)
+
+               # render disk throughput
+               max_sample = max (trace.disk_stats, key = lambda s: s.tput)
+               if clip_visible (clip, chart_rect):
+                       draw_chart (ctx, DISK_TPUT_COLOR, False, chart_rect, \
+                                   [(sample.time, sample.tput) for sample in trace.disk_stats], \
+                                   proc_tree, None)
+
+               pos_x = off_x + ((max_sample.time - proc_tree.start_time) * w / proc_tree.duration)
+
+               shift_x, shift_y = -20, 20
+               if (pos_x < off_x + 245):
+                       shift_x, shift_y = 5, 40
+
+               label = "%dMB/s" % round ((max_sample.tput) / 1024.0)
+               draw_text (ctx, label, DISK_TPUT_COLOR, pos_x + shift_x, curr_y + shift_y)
+
+               curr_y = curr_y + 30 + bar_h
 
        # render mem usage
        chart_rect = (off_x, curr_y+30, w, meminfo_bar_h)