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 | |
parent | ee302247199b720dafc1cacd8d4585331ebd0e67 (diff) |
update chart color
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rw-r--r-- | draw.py | 20 | ||||
-rw-r--r-- | parsing.py | 5 | ||||
-rw-r--r-- | process_tree.py | 59 |
3 files changed, 44 insertions, 40 deletions
@@ -45,7 +45,8 @@ AXIS_FONT_SIZE = 11 LEGEND_FONT_SIZE = 12 # CPU load chart color. -CPU_COLOR = (0.40, 0.55, 0.70, 1.0) +#CPU_COLOR = (0.40, 0.55, 0.70, 1.0) +CPU_COLOR = (1, 0, 1, 1.0) # IO wait chart color. IO_COLOR = (1, 0, 0, 1) # Disk throughput color. @@ -57,20 +58,20 @@ FILE_OPEN_COLOR = (0.20, 0.71, 0.71, 1.0) # Process border color. PROC_BORDER_COLOR = (0.71, 0.71, 0.71, 1.0) -# Waiting process color. -PROC_COLOR_D = (0.76, 0.48, 0.48, 0.125) # Running process color. PROC_COLOR_R = CPU_COLOR +# Waiting process color. +PROC_COLOR_D = (0, 0, 1, 0.5) # Sleeping process color. -PROC_COLOR_S = (0.94, 0.94, 0.94, 1.0) +PROC_COLOR_S = (0, 1, 1, 1.0) # Stopped process color. -PROC_COLOR_T = (0.94, 0.50, 0.50, 1.0) +PROC_COLOR_T = (1, 0, 0, 1.0) # Zombie process color. -PROC_COLOR_Z = (0.71, 0.71, 0.71, 1.0) +PROC_COLOR_Z = (0, 1, 0, 1.0) # Dead process color. -PROC_COLOR_X = (0.71, 0.71, 0.71, 0.125) +PROC_COLOR_X = (1, 1, 0, 1) # Paging process color. -PROC_COLOR_W = (0.71, 0.71, 0.71, 0.125) +PROC_COLOR_W = (1, 1, 1, 1) # Process label color. PROC_TEXT_COLOR = (0.19, 0.19, 0.19, 1.0) @@ -232,8 +233,9 @@ OPTIONS = None def extents(headers, cpu_stats, disk_stats, proc_tree, times): + disk_chart_num = sum(1 for disk in disk_stats.keys() if max(sample.util for sample in disk_stats[disk]) > 0) w = (proc_tree.duration * sec_w / 100) + 2*off_x - h = proc_h * proc_tree.num_proc + header_h + 2*off_y + h = proc_h * proc_tree.num_proc + header_h + 2*off_y + ( 30 + bar_h )* (len(cpu_stats) + disk_chart_num - 2 ) return (w,h) # @@ -71,11 +71,14 @@ def _parse_proc_ps_log(writer, file): timed_blocks = _parse_timed_blocks(file) for time, lines in timed_blocks: for line in lines: - print("====%s %s===" %(time, line)) + ##print("====%s %s===" %(time, line)) tokens = line.split(' ') offset = [index for index, token in enumerate(tokens[1:]) if token[-1] == ')'][0] pid, cmd, state, ppid = int(tokens[0]), ' '.join(tokens[1:2+offset]), tokens[2+offset], int(tokens[3+offset]) + ## userCpu: Amount of time that this process has been scheduled in user mode + ## sysCpu: Amount of time that this process has been scheduled in kernel mode + ## stime: The time process started after system boot userCpu, sysCpu, stime= int(tokens[13+offset]), int(tokens[14+offset]), int(tokens[21+offset]) if pid in processMap: 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 |