summaryrefslogtreecommitdiffstats
path: root/scripts/pybootchartgui
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-11-30 10:50:09 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-07 10:37:59 +0000
commit820c042b3603b4ab2a1e439c765085797859efe9 (patch)
tree04b5a1af836fac64ce0dd3a9232634c5bfe305a6 /scripts/pybootchartgui
parent6b5037bf2cbf274ed3e8a7aee3fe9a1b2e039e84 (diff)
downloadpoky-820c042b3603b4ab2a1e439c765085797859efe9.tar.gz
pybootchartgui: simplify drawing of memory usage
The internal representation after parsing now matches exactly what the drawing code needs, thus speeding up drawing a bit. However, the main motivation is to store exactly that required information in a more compact file. (From OE-Core rev: ca06e67a0bb5820b38fda4c8dfee20764c1e59ae) 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>
Diffstat (limited to 'scripts/pybootchartgui')
-rw-r--r--scripts/pybootchartgui/pybootchartgui/draw.py12
-rw-r--r--scripts/pybootchartgui/pybootchartgui/parsing.py2
-rw-r--r--scripts/pybootchartgui/pybootchartgui/samples.py16
3 files changed, 23 insertions, 7 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui/draw.py b/scripts/pybootchartgui/pybootchartgui/draw.py
index f0143ad0d6..201ce4577f 100644
--- a/scripts/pybootchartgui/pybootchartgui/draw.py
+++ b/scripts/pybootchartgui/pybootchartgui/draw.py
@@ -463,25 +463,25 @@ def render_charts(ctx, options, clip, trace, curr_y, w, h, sec_w):
463 chart_rect = (off_x, curr_y+30, w, meminfo_bar_h) 463 chart_rect = (off_x, curr_y+30, w, meminfo_bar_h)
464 mem_stats = trace.mem_stats 464 mem_stats = trace.mem_stats
465 if mem_stats and clip_visible (clip, chart_rect): 465 if mem_stats and clip_visible (clip, chart_rect):
466 mem_scale = max(sample.records['MemTotal'] - sample.records['MemFree'] for sample in mem_stats) 466 mem_scale = max(sample.buffers for sample in mem_stats)
467 draw_legend_box(ctx, "Mem cached (scale: %u MiB)" % (float(mem_scale) / 1024), MEM_CACHED_COLOR, off_x, curr_y+20, leg_s) 467 draw_legend_box(ctx, "Mem cached (scale: %u MiB)" % (float(mem_scale) / 1024), MEM_CACHED_COLOR, off_x, curr_y+20, leg_s)
468 draw_legend_box(ctx, "Used", MEM_USED_COLOR, off_x + 240, curr_y+20, leg_s) 468 draw_legend_box(ctx, "Used", MEM_USED_COLOR, off_x + 240, curr_y+20, leg_s)
469 draw_legend_box(ctx, "Buffers", MEM_BUFFERS_COLOR, off_x + 360, curr_y+20, leg_s) 469 draw_legend_box(ctx, "Buffers", MEM_BUFFERS_COLOR, off_x + 360, curr_y+20, leg_s)
470 draw_legend_line(ctx, "Swap (scale: %u MiB)" % max([(sample.records['SwapTotal'] - sample.records['SwapFree'])/1024 for sample in mem_stats]), \ 470 draw_legend_line(ctx, "Swap (scale: %u MiB)" % max([(sample.swap)/1024 for sample in mem_stats]), \
471 MEM_SWAP_COLOR, off_x + 480, curr_y+20, leg_s) 471 MEM_SWAP_COLOR, off_x + 480, curr_y+20, leg_s)
472 draw_box_ticks(ctx, chart_rect, sec_w) 472 draw_box_ticks(ctx, chart_rect, sec_w)
473 draw_annotations(ctx, proc_tree, trace.times, chart_rect) 473 draw_annotations(ctx, proc_tree, trace.times, chart_rect)
474 draw_chart(ctx, MEM_BUFFERS_COLOR, True, chart_rect, \ 474 draw_chart(ctx, MEM_BUFFERS_COLOR, True, chart_rect, \
475 [(sample.time, sample.records['MemTotal'] - sample.records['MemFree']) for sample in trace.mem_stats], \ 475 [(sample.time, sample.buffers) for sample in trace.mem_stats], \
476 proc_tree, [0, mem_scale]) 476 proc_tree, [0, mem_scale])
477 draw_chart(ctx, MEM_USED_COLOR, True, chart_rect, \ 477 draw_chart(ctx, MEM_USED_COLOR, True, chart_rect, \
478 [(sample.time, sample.records['MemTotal'] - sample.records['MemFree'] - sample.records['Buffers']) for sample in mem_stats], \ 478 [(sample.time, sample.used) for sample in mem_stats], \
479 proc_tree, [0, mem_scale]) 479 proc_tree, [0, mem_scale])
480 draw_chart(ctx, MEM_CACHED_COLOR, True, chart_rect, \ 480 draw_chart(ctx, MEM_CACHED_COLOR, True, chart_rect, \
481 [(sample.time, sample.records['Cached']) for sample in mem_stats], \ 481 [(sample.time, sample.cached) for sample in mem_stats], \
482 proc_tree, [0, mem_scale]) 482 proc_tree, [0, mem_scale])
483 draw_chart(ctx, MEM_SWAP_COLOR, False, chart_rect, \ 483 draw_chart(ctx, MEM_SWAP_COLOR, False, chart_rect, \
484 [(sample.time, float(sample.records['SwapTotal'] - sample.records['SwapFree'])) for sample in mem_stats], \ 484 [(sample.time, float(sample.swap)) for sample in mem_stats], \
485 proc_tree, None) 485 proc_tree, None)
486 486
487 curr_y = curr_y + meminfo_bar_h 487 curr_y = curr_y + meminfo_bar_h
diff --git a/scripts/pybootchartgui/pybootchartgui/parsing.py b/scripts/pybootchartgui/pybootchartgui/parsing.py
index 301145ab67..1c8d8efed7 100644
--- a/scripts/pybootchartgui/pybootchartgui/parsing.py
+++ b/scripts/pybootchartgui/pybootchartgui/parsing.py
@@ -503,7 +503,7 @@ def _parse_proc_meminfo_log(file):
503 sample.add_value(match.group(1), int(match.group(2))) 503 sample.add_value(match.group(1), int(match.group(2)))
504 504
505 if sample.valid(): 505 if sample.valid():
506 mem_stats.append(sample) 506 mem_stats.append(DrawMemSample(sample))
507 507
508 return mem_stats 508 return mem_stats
509 509
diff --git a/scripts/pybootchartgui/pybootchartgui/samples.py b/scripts/pybootchartgui/pybootchartgui/samples.py
index bedca4165a..9fc309b3ab 100644
--- a/scripts/pybootchartgui/pybootchartgui/samples.py
+++ b/scripts/pybootchartgui/pybootchartgui/samples.py
@@ -53,6 +53,22 @@ class MemSample:
53 # discard incomplete samples 53 # discard incomplete samples
54 return [v for v in MemSample.used_values if v not in keys] == [] 54 return [v for v in MemSample.used_values if v not in keys] == []
55 55
56class DrawMemSample:
57 """
58 Condensed version of a MemSample with exactly the values used by the drawing code.
59 Initialized either from a valid MemSample or
60 a tuple/list of buffer/used/cached/swap values.
61 """
62 def __init__(self, mem_sample):
63 self.time = mem_sample.time
64 if isinstance(mem_sample, MemSample):
65 self.buffers = mem_sample.records['MemTotal'] - mem_sample.records['MemFree']
66 self.used = mem_sample.records['MemTotal'] - mem_sample.records['MemFree'] - mem_sample.records['Buffers']
67 self.cached = mem_sample.records['Cached']
68 self.swap = mem_sample.records['SwapTotal'] - mem_sample.records['SwapFree']
69 else:
70 self.buffers, self.used, self.cached, self.swap = mem_sample
71
56class DiskSpaceSample: 72class DiskSpaceSample:
57 def __init__(self, time): 73 def __init__(self, time):
58 self.time = time 74 self.time = time