diff options
Diffstat (limited to 'scripts/pybootchartgui')
-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(): help="image format (...); default format ...") parser.add_option("-o", "--output", dest="output", metavar="PATH", default=None, help="output path (file or directory) where charts are stored") + parser.add_option("-s", "--split", dest="num", type=int, default=1, + help="split the output chart into <NUM> charts, only works with \"-o PATH\"") parser.add_option("-n", "--no-prune", action="store_false", dest="prune", default=True, help="do not prune the process tree") parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, @@ -59,8 +61,16 @@ def main(argv=None): gui.show(res) else: filename = _get_filename(args, options) - batch.render(res, options.format, filename) - print "bootchart written to", filename + res_list = parsing.split_res(res, options.num) + n = 1 + for r in res_list: + if len(res_list) == 1: + f = filename + "." + options.format + else: + f = filename + "_" + str(n) + "." + options.format + n = n + 1 + batch.render(r, options.format, f) + print "bootchart written to", f return 0 except parsing.ParseError, ex: 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): #monitored_app = state.headers.get("profile.process") #proc_tree = ProcessTree(state.ps_stats, monitored_app, prune) return state + +def split_res(res, n): + """ Split the res into n pieces """ + res_list = [] + if n > 1: + s_list = sorted(res.start.keys()) + frag_size = len(s_list) / float(n) + # Need the top value + if frag_size > int(frag_size): + frag_size = int(frag_size + 1) + else: + frag_size = int(frag_size) + + start = 0 + end = frag_size + while start < end: + state = ParserState() + for i in range(start, end): + # Add these lines for reference + #state.processes[pn + ":" + task] = [start, end] + #state.start[start] = pn + ":" + task + #state.end[end] = pn + ":" + task + p = res.start[s_list[i]] + s = s_list[i] + e = res.processes[p][1] + state.processes[p] = [s, e] + state.start[s] = p + state.end[e] = p + start = end + end = end + frag_size + if end > len(s_list): + end = len(s_list) + res_list.append(state) + else: + res_list.append(res) + return res_list |