diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2012-06-06 14:10:11 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-15 15:12:42 +0100 |
commit | 0ad3f754324eb6337243ca7d28f32b047eca0b51 (patch) | |
tree | aab89171bd438b0d66be71c847aeccf185114bb9 | |
parent | bc5b86f025c9c1d9f0e1a58e92fe8c1381c096a5 (diff) | |
download | poky-0ad3f754324eb6337243ca7d28f32b047eca0b51.tar.gz |
pybootchartgui: split the output chart into multiple ones
Split the output chart into multiple ones to make it more readable, it
only works with "-o path", which means that it doesn't work if the user
doesn't want to save the chart to the disk. For example:
$ ./pybootchartgui.py /path/to/tmp/buildstats/core-image-sato-qemux86/201205301810/ -f svg -s 5 -o /tmp/
bootchart written to /tmp/bootchart_1.svg
bootchart written to /tmp/bootchart_2.svg
bootchart written to /tmp/bootchart_3.svg
bootchart written to /tmp/bootchart_4.svg
bootchart written to /tmp/bootchart_5.svg
[YOCTO #2403]
(From OE-Core rev: 04a34899e1c15a70babd97a3a59ccb9f8af05bad)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/pybootchartgui/pybootchartgui/main.py | 14 | ||||
-rw-r--r-- | scripts/pybootchartgui/pybootchartgui/parsing.py | 36 |
2 files changed, 48 insertions, 2 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui/main.py b/scripts/pybootchartgui/pybootchartgui/main.py index bf50afb6c3..fce8dd35cf 100644 --- a/scripts/pybootchartgui/pybootchartgui/main.py +++ b/scripts/pybootchartgui/pybootchartgui/main.py | |||
@@ -17,6 +17,8 @@ def _mk_options_parser(): | |||
17 | help="image format (...); default format ...") | 17 | help="image format (...); default format ...") |
18 | parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None, | 18 | parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None, |
19 | help="output path (file or directory) where charts are stored") | 19 | help="output path (file or directory) where charts are stored") |
20 | parser.add_option("-s", "--split", dest="num", type=int, default=1, | ||
21 | help="split the output chart into <NUM> charts, only works with \"-o PATH\"") | ||
20 | parser.add_option("-n", "--no-prune", action="store_false", dest="prune", default=True, | 22 | parser.add_option("-n", "--no-prune", action="store_false", dest="prune", default=True, |
21 | help="do not prune the process tree") | 23 | help="do not prune the process tree") |
22 | parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, | 24 | parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, |
@@ -59,8 +61,16 @@ def main(argv=None): | |||
59 | gui.show(res) | 61 | gui.show(res) |
60 | else: | 62 | else: |
61 | filename = _get_filename(args, options) | 63 | filename = _get_filename(args, options) |
62 | batch.render(res, options.format, filename) | 64 | res_list = parsing.split_res(res, options.num) |
63 | print "bootchart written to", filename | 65 | n = 1 |
66 | for r in res_list: | ||
67 | if len(res_list) == 1: | ||
68 | f = filename + "." + options.format | ||
69 | else: | ||
70 | f = filename + "_" + str(n) + "." + options.format | ||
71 | n = n + 1 | ||
72 | batch.render(r, options.format, f) | ||
73 | print "bootchart written to", f | ||
64 | return 0 | 74 | return 0 |
65 | except parsing.ParseError, ex: | 75 | except parsing.ParseError, ex: |
66 | print("Parse error: %s" % ex) | 76 | print("Parse error: %s" % ex) |
diff --git a/scripts/pybootchartgui/pybootchartgui/parsing.py b/scripts/pybootchartgui/pybootchartgui/parsing.py index 11a082941c..c64eba0a4d 100644 --- a/scripts/pybootchartgui/pybootchartgui/parsing.py +++ b/scripts/pybootchartgui/pybootchartgui/parsing.py | |||
@@ -226,3 +226,39 @@ def parse(paths, prune): | |||
226 | #monitored_app = state.headers.get("profile.process") | 226 | #monitored_app = state.headers.get("profile.process") |
227 | #proc_tree = ProcessTree(state.ps_stats, monitored_app, prune) | 227 | #proc_tree = ProcessTree(state.ps_stats, monitored_app, prune) |
228 | return state | 228 | return state |
229 | |||
230 | def split_res(res, n): | ||
231 | """ Split the res into n pieces """ | ||
232 | res_list = [] | ||
233 | if n > 1: | ||
234 | s_list = sorted(res.start.keys()) | ||
235 | frag_size = len(s_list) / float(n) | ||
236 | # Need the top value | ||
237 | if frag_size > int(frag_size): | ||
238 | frag_size = int(frag_size + 1) | ||
239 | else: | ||
240 | frag_size = int(frag_size) | ||
241 | |||
242 | start = 0 | ||
243 | end = frag_size | ||
244 | while start < end: | ||
245 | state = ParserState() | ||
246 | for i in range(start, end): | ||
247 | # Add these lines for reference | ||
248 | #state.processes[pn + ":" + task] = [start, end] | ||
249 | #state.start[start] = pn + ":" + task | ||
250 | #state.end[end] = pn + ":" + task | ||
251 | p = res.start[s_list[i]] | ||
252 | s = s_list[i] | ||
253 | e = res.processes[p][1] | ||
254 | state.processes[p] = [s, e] | ||
255 | state.start[s] = p | ||
256 | state.end[e] = p | ||
257 | start = end | ||
258 | end = end + frag_size | ||
259 | if end > len(s_list): | ||
260 | end = len(s_list) | ||
261 | res_list.append(state) | ||
262 | else: | ||
263 | res_list.append(res) | ||
264 | return res_list | ||