summaryrefslogtreecommitdiffstats
path: root/scripts/pybootchartgui/pybootchartgui/draw.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pybootchartgui/pybootchartgui/draw.py')
-rw-r--r--scripts/pybootchartgui/pybootchartgui/draw.py98
1 files changed, 50 insertions, 48 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui/draw.py b/scripts/pybootchartgui/pybootchartgui/draw.py
index bddd8048c9..ec5dd333a1 100644
--- a/scripts/pybootchartgui/pybootchartgui/draw.py
+++ b/scripts/pybootchartgui/pybootchartgui/draw.py
@@ -344,56 +344,58 @@ def render_charts(ctx, options, clip, trace, curr_y, w, h, sec_w):
344 proc_tree = options.proc_tree(trace) 344 proc_tree = options.proc_tree(trace)
345 345
346 # render bar legend 346 # render bar legend
347 ctx.set_font_size(LEGEND_FONT_SIZE) 347 if trace.cpu_stats:
348 348 ctx.set_font_size(LEGEND_FONT_SIZE)
349 draw_legend_box(ctx, "CPU (user+sys)", CPU_COLOR, off_x, curr_y+20, leg_s) 349
350 draw_legend_box(ctx, "I/O (wait)", IO_COLOR, off_x + 120, curr_y+20, leg_s) 350 draw_legend_box(ctx, "CPU (user+sys)", CPU_COLOR, off_x, curr_y+20, leg_s)
351 351 draw_legend_box(ctx, "I/O (wait)", IO_COLOR, off_x + 120, curr_y+20, leg_s)
352 # render I/O wait 352
353 chart_rect = (off_x, curr_y+30, w, bar_h) 353 # render I/O wait
354 if clip_visible (clip, chart_rect): 354 chart_rect = (off_x, curr_y+30, w, bar_h)
355 draw_box_ticks (ctx, chart_rect, sec_w) 355 if clip_visible (clip, chart_rect):
356 draw_annotations (ctx, proc_tree, trace.times, chart_rect) 356 draw_box_ticks (ctx, chart_rect, sec_w)
357 draw_chart (ctx, IO_COLOR, True, chart_rect, \ 357 draw_annotations (ctx, proc_tree, trace.times, chart_rect)
358 [(sample.time, sample.user + sample.sys + sample.io) for sample in trace.cpu_stats], \ 358 draw_chart (ctx, IO_COLOR, True, chart_rect, \
359 proc_tree, None) 359 [(sample.time, sample.user + sample.sys + sample.io) for sample in trace.cpu_stats], \
360 # render CPU load 360 proc_tree, None)
361 draw_chart (ctx, CPU_COLOR, True, chart_rect, \ 361 # render CPU load
362 [(sample.time, sample.user + sample.sys) for sample in trace.cpu_stats], \ 362 draw_chart (ctx, CPU_COLOR, True, chart_rect, \
363 proc_tree, None) 363 [(sample.time, sample.user + sample.sys) for sample in trace.cpu_stats], \
364 364 proc_tree, None)
365 curr_y = curr_y + 30 + bar_h 365
366 curr_y = curr_y + 30 + bar_h
366 367
367 # render second chart 368 # render second chart
368 draw_legend_line(ctx, "Disk throughput", DISK_TPUT_COLOR, off_x, curr_y+20, leg_s) 369 if trace.disk_stats:
369 draw_legend_box(ctx, "Disk utilization", IO_COLOR, off_x + 120, curr_y+20, leg_s) 370 draw_legend_line(ctx, "Disk throughput", DISK_TPUT_COLOR, off_x, curr_y+20, leg_s)
370 371 draw_legend_box(ctx, "Disk utilization", IO_COLOR, off_x + 120, curr_y+20, leg_s)
371 # render I/O utilization 372
372 chart_rect = (off_x, curr_y+30, w, bar_h) 373 # render I/O utilization
373 if clip_visible (clip, chart_rect): 374 chart_rect = (off_x, curr_y+30, w, bar_h)
374 draw_box_ticks (ctx, chart_rect, sec_w) 375 if clip_visible (clip, chart_rect):
375 draw_annotations (ctx, proc_tree, trace.times, chart_rect) 376 draw_box_ticks (ctx, chart_rect, sec_w)
376 draw_chart (ctx, IO_COLOR, True, chart_rect, \ 377 draw_annotations (ctx, proc_tree, trace.times, chart_rect)
377 [(sample.time, sample.util) for sample in trace.disk_stats], \ 378 draw_chart (ctx, IO_COLOR, True, chart_rect, \
378 proc_tree, None) 379 [(sample.time, sample.util) for sample in trace.disk_stats], \
379 380 proc_tree, None)
380 # render disk throughput 381
381 max_sample = max (trace.disk_stats, key = lambda s: s.tput) 382 # render disk throughput
382 if clip_visible (clip, chart_rect): 383 max_sample = max (trace.disk_stats, key = lambda s: s.tput)
383 draw_chart (ctx, DISK_TPUT_COLOR, False, chart_rect, \ 384 if clip_visible (clip, chart_rect):
384 [(sample.time, sample.tput) for sample in trace.disk_stats], \ 385 draw_chart (ctx, DISK_TPUT_COLOR, False, chart_rect, \
385 proc_tree, None) 386 [(sample.time, sample.tput) for sample in trace.disk_stats], \
386 387 proc_tree, None)
387 pos_x = off_x + ((max_sample.time - proc_tree.start_time) * w / proc_tree.duration) 388
388 389 pos_x = off_x + ((max_sample.time - proc_tree.start_time) * w / proc_tree.duration)
389 shift_x, shift_y = -20, 20 390
390 if (pos_x < off_x + 245): 391 shift_x, shift_y = -20, 20
391 shift_x, shift_y = 5, 40 392 if (pos_x < off_x + 245):
392 393 shift_x, shift_y = 5, 40
393 label = "%dMB/s" % round ((max_sample.tput) / 1024.0) 394
394 draw_text (ctx, label, DISK_TPUT_COLOR, pos_x + shift_x, curr_y + shift_y) 395 label = "%dMB/s" % round ((max_sample.tput) / 1024.0)
395 396 draw_text (ctx, label, DISK_TPUT_COLOR, pos_x + shift_x, curr_y + shift_y)
396 curr_y = curr_y + 30 + bar_h 397
398 curr_y = curr_y + 30 + bar_h
397 399
398 # render mem usage 400 # render mem usage
399 chart_rect = (off_x, curr_y+30, w, meminfo_bar_h) 401 chart_rect = (off_x, curr_y+30, w, meminfo_bar_h)