diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2017-04-01 22:27:54 +0800 |
---|---|---|
committer | Yongqin Liu <yongqin.liu@linaro.org> | 2017-04-01 22:27:54 +0800 |
commit | a0afd7a2c52b2e101c68b03ef8f84cf49b4644b4 (patch) | |
tree | 6abe27b2aed5b0a7c9b3b2158645ab5779597dce /process_tree.py | |
parent | ee302247199b720dafc1cacd8d4585331ebd0e67 (diff) |
update chart color
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Diffstat (limited to 'process_tree.py')
-rw-r--r-- | process_tree.py | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/process_tree.py b/process_tree.py index 0cacbe3..657fcde 100644 --- a/process_tree.py +++ b/process_tree.py @@ -40,11 +40,11 @@ class ProcessTree: def __init__(self, writer, psstats, monitoredApp, prune, idle, for_testing = False): self.writer = writer self.process_tree = [] - self.psstats = psstats - self.process_list = sorted(psstats.process_list, key = lambda p: p.pid) - self.sample_period = psstats.sample_period + self.psstats = psstats + self.process_list = sorted(psstats.process_list, key = lambda p: p.pid) + self.sample_period = psstats.sample_period - self.build() + self.build() self.update_ppids_for_daemons(self.process_list) self.start_time = self.get_start_time(self.process_tree) @@ -55,31 +55,31 @@ class ProcessTree: if for_testing: return - removed = self.merge_logger(self.process_tree, self.LOGGER_PROC, monitoredApp, False) - writer.status("merged %i logger processes" % removed) + removed = self.merge_logger(self.process_tree, self.LOGGER_PROC, monitoredApp, False) + writer.status("merged %i logger processes" % removed) - if prune: + if prune: p_processes = self.prune(self.process_tree, None) - p_exploders = self.merge_exploders(self.process_tree, self.EXPLODER_PROCESSES) - p_threads = self.merge_siblings(self.process_tree) - p_runs = self.merge_runs(self.process_tree) - writer.status("pruned %i process, %i exploders, %i threads, and %i runs" % (p_processes, p_exploders, p_threads, p_runs)) + p_exploders = self.merge_exploders(self.process_tree, self.EXPLODER_PROCESSES) + p_threads = self.merge_siblings(self.process_tree) + p_runs = self.merge_runs(self.process_tree) + writer.status("pruned %i process, %i exploders, %i threads, and %i runs" % (p_processes, p_exploders, p_threads, p_runs)) self.sort(self.process_tree) - self.start_time = self.get_start_time(self.process_tree) + self.start_time = self.get_start_time(self.process_tree) self.end_time = self.get_end_time(self.process_tree) - self.duration = self.end_time - self.start_time + self.duration = self.end_time - self.start_time - self.num_proc = self.num_nodes(self.process_tree) + self.num_proc = self.num_nodes(self.process_tree) def build(self): """Build the process tree from the list of top samples.""" self.process_tree = [] - for proc in self.process_list: + for proc in self.process_list: if not proc.parent: self.process_tree.append(proc) - else: + else: proc.parent.child_list.append(proc) def sort(self, process_subtree): @@ -97,7 +97,7 @@ class ProcessTree: def get_start_time(self, process_subtree): """Returns the start time of the process subtree. This is the start - time of the earliest process. + time of the earliest process. """ if not process_subtree: @@ -142,17 +142,17 @@ class ProcessTree: for p in process_list: p.child_list = [] self.build() - + def prune(self, process_subtree, parent): """Prunes the process tree by removing idle processes and processes - that only live for the duration of a single top sample. Sibling - processes with the same command line (i.e. threads) are merged - together. This filters out sleepy background processes, short-lived - processes and bootcharts' analysis tools. + that only live for the duration of a single top sample. Sibling + processes with the same command line (i.e. threads) are merged + together. This filters out sleepy background processes, short-lived + processes and bootcharts' analysis tools. """ def is_idle_background_process_without_children(p): process_end = p.start_time + p.duration - return not p.active and \ + return not p.active and \ process_end >= self.start_time + self.duration and \ p.start_time > self.start_time and \ p.duration > 0.9 * self.duration and \ @@ -187,8 +187,8 @@ class ProcessTree: def merge_logger(self, process_subtree, logger_proc, monitored_app, app_tree): """Merges the logger's process subtree. The logger will typically - spawn lots of sleep and cat processes, thus polluting the - process tree. + spawn lots of sleep and cat processes, thus polluting the + process tree. """ num_removed = 0 @@ -197,7 +197,7 @@ class ProcessTree: if logger_proc == p.cmd and not app_tree: is_app_tree = True num_removed += self.merge_logger(p.child_list, logger_proc, monitored_app, is_app_tree) - # don't remove the logger itself + # don't remove the logger itself continue if app_tree and monitored_app != None and monitored_app == p.cmd: @@ -214,7 +214,7 @@ class ProcessTree: def merge_exploders(self, process_subtree, processes): """Merges specific process subtrees (used for processes which usually - spawn huge meaningless process trees). + spawn huge meaningless process trees). """ num_removed = 0 @@ -232,8 +232,7 @@ class ProcessTree: def merge_siblings(self,process_subtree): """Merges thread processes. Sibling processes with the same command - line are merged together. - + line are merged together. """ num_removed = 0 idx = 0 @@ -255,7 +254,7 @@ class ProcessTree: def merge_runs(self, process_subtree): """Merges process runs. Single child processes which share the same - command line with the parent are merged. + command line with the parent are merged. """ num_removed = 0 |