diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-11-19 15:03:09 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-11-20 15:31:48 +0000 |
commit | 077291583ce5a62d0b72093dc5e446a706a7fdfb (patch) | |
tree | 06264d64f3ff0ddf4d48811aa9758d3f12a89b7b | |
parent | 295f1608b050af3bf73b3cd6eaadb9a52a6b4822 (diff) | |
download | poky-077291583ce5a62d0b72093dc5e446a706a7fdfb.tar.gz |
scripts/pybootchart: Allow minimum task length to be configured from the commandline
Rather than hardcode the value of "8", allow the minimum task length to be
configured from the commandline using the -m option. "-m 0" means all
tasks will be graphed.
(From OE-Core rev: 30001153d3ce7dadf8f1ec79e634a638a9994518)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/pybootchartgui/pybootchartgui/main.py | 4 | ||||
-rw-r--r-- | scripts/pybootchartgui/pybootchartgui/parsing.py | 18 |
2 files changed, 12 insertions, 10 deletions
diff --git a/scripts/pybootchartgui/pybootchartgui/main.py b/scripts/pybootchartgui/pybootchartgui/main.py index e70ab13661..e22636c23e 100644 --- a/scripts/pybootchartgui/pybootchartgui/main.py +++ b/scripts/pybootchartgui/pybootchartgui/main.py | |||
@@ -19,6 +19,8 @@ def _mk_options_parser(): | |||
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, | 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\"") | 21 | help="split the output chart into <NUM> charts, only works with \"-o PATH\"") |
22 | parser.add_option("-m", "--mintime", dest="mintime", type=int, default=8, | ||
23 | help="only tasks longer than this time will be displayed") | ||
22 | parser.add_option("-n", "--no-prune", action="store_false", dest="prune", default=True, | 24 | parser.add_option("-n", "--no-prune", action="store_false", dest="prune", default=True, |
23 | help="do not prune the process tree") | 25 | help="do not prune the process tree") |
24 | parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, | 26 | parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, |
@@ -51,7 +53,7 @@ def main(argv=None): | |||
51 | parser.error("insufficient arguments, expected at least one path.") | 53 | parser.error("insufficient arguments, expected at least one path.") |
52 | return 2 | 54 | return 2 |
53 | 55 | ||
54 | res = parsing.parse(args, options.prune) | 56 | res = parsing.parse(args, options.prune, options.mintime) |
55 | if options.interactive or options.output == None: | 57 | if options.interactive or options.output == None: |
56 | gui.show(res) | 58 | gui.show(res) |
57 | else: | 59 | else: |
diff --git a/scripts/pybootchartgui/pybootchartgui/parsing.py b/scripts/pybootchartgui/pybootchartgui/parsing.py index a0f6e8e0eb..6343fd5a7b 100644 --- a/scripts/pybootchartgui/pybootchartgui/parsing.py +++ b/scripts/pybootchartgui/pybootchartgui/parsing.py | |||
@@ -170,7 +170,7 @@ class ParserState: | |||
170 | 170 | ||
171 | _relevant_files = set(["header", "proc_diskstats.log", "proc_ps.log", "proc_stat.log"]) | 171 | _relevant_files = set(["header", "proc_diskstats.log", "proc_ps.log", "proc_stat.log"]) |
172 | 172 | ||
173 | def _do_parse(state, filename, file): | 173 | def _do_parse(state, filename, file, mintime): |
174 | #print filename | 174 | #print filename |
175 | #writer.status("parsing '%s'" % filename) | 175 | #writer.status("parsing '%s'" % filename) |
176 | paths = filename.split("/") | 176 | paths = filename.split("/") |
@@ -183,7 +183,7 @@ def _do_parse(state, filename, file): | |||
183 | start = int(float(line.split()[-1])) | 183 | start = int(float(line.split()[-1])) |
184 | elif line.startswith("Ended:"): | 184 | elif line.startswith("Ended:"): |
185 | end = int(float(line.split()[-1])) | 185 | end = int(float(line.split()[-1])) |
186 | if start and end and (end - start) > 8: | 186 | if start and end and (end - start) >= mintime: |
187 | k = pn + ":" + task | 187 | k = pn + ":" + task |
188 | state.processes[pn + ":" + task] = [start, end] | 188 | state.processes[pn + ":" + task] = [start, end] |
189 | if start not in state.start: | 189 | if start not in state.start: |
@@ -196,12 +196,12 @@ def _do_parse(state, filename, file): | |||
196 | state.end[end].append(pn + ":" + task) | 196 | state.end[end].append(pn + ":" + task) |
197 | return state | 197 | return state |
198 | 198 | ||
199 | def parse_file(state, filename): | 199 | def parse_file(state, filename, mintime): |
200 | basename = os.path.basename(filename) | 200 | basename = os.path.basename(filename) |
201 | with open(filename, "rb") as file: | 201 | with open(filename, "rb") as file: |
202 | return _do_parse(state, filename, file) | 202 | return _do_parse(state, filename, file, mintime) |
203 | 203 | ||
204 | def parse_paths(state, paths): | 204 | def parse_paths(state, paths, mintime): |
205 | for path in paths: | 205 | for path in paths: |
206 | root,extension = os.path.splitext(path) | 206 | root,extension = os.path.splitext(path) |
207 | if not(os.path.exists(path)): | 207 | if not(os.path.exists(path)): |
@@ -210,7 +210,7 @@ def parse_paths(state, paths): | |||
210 | if os.path.isdir(path): | 210 | if os.path.isdir(path): |
211 | files = [ f for f in [os.path.join(path, f) for f in os.listdir(path)] ] | 211 | files = [ f for f in [os.path.join(path, f) for f in os.listdir(path)] ] |
212 | files.sort() | 212 | files.sort() |
213 | state = parse_paths(state, files) | 213 | state = parse_paths(state, files, mintime) |
214 | elif extension in [".tar", ".tgz", ".tar.gz"]: | 214 | elif extension in [".tar", ".tgz", ".tar.gz"]: |
215 | tf = None | 215 | tf = None |
216 | try: | 216 | try: |
@@ -223,11 +223,11 @@ def parse_paths(state, paths): | |||
223 | if tf != None: | 223 | if tf != None: |
224 | tf.close() | 224 | tf.close() |
225 | else: | 225 | else: |
226 | state = parse_file(state, path) | 226 | state = parse_file(state, path, mintime) |
227 | return state | 227 | return state |
228 | 228 | ||
229 | def parse(paths, prune): | 229 | def parse(paths, prune, mintime): |
230 | state = parse_paths(ParserState(), paths) | 230 | state = parse_paths(ParserState(), paths, mintime) |
231 | if not state.valid(): | 231 | if not state.valid(): |
232 | raise ParseError("empty state: '%s' does not contain a valid bootchart" % ", ".join(paths)) | 232 | raise ParseError("empty state: '%s' does not contain a valid bootchart" % ", ".join(paths)) |
233 | #monitored_app = state.headers.get("profile.process") | 233 | #monitored_app = state.headers.get("profile.process") |