summaryrefslogtreecommitdiffstats
path: root/scripts/pybootchartgui
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pybootchartgui')
-rw-r--r--scripts/pybootchartgui/pybootchartgui/main.py4
-rw-r--r--scripts/pybootchartgui/pybootchartgui/parsing.py18
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
173def _do_parse(state, filename, file): 173def _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
199def parse_file(state, filename): 199def 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
204def parse_paths(state, paths): 204def 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
229def parse(paths, prune): 229def 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")