pybootchartgui/draw.py: skip empty CPU and disk usage charts

The only real change is the addition of two if checks that skips the
corresponding drawing code when there is no data.

(From OE-Core rev: 1658fd5e9ca1ba793cae604c2a395d54e3ec9056)

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Patrick Ohly 2016-11-30 10:50:05 +01:00 committed by Richard Purdie
parent 521887ea61
commit 1416bb3244
1 changed files with 41 additions and 39 deletions

View 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)
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)
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)
# 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
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)
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 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)
# 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)
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
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)
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
curr_y = curr_y + 30 + bar_h
# render mem usage
chart_rect = (off_x, curr_y+30, w, meminfo_bar_h)