diff options
author | Pierre Tardy <pierre.tardy@intel.com> | 2011-03-22 13:40:03 +0100 |
---|---|---|
committer | Pierre Tardy <pierre.tardy@intel.com> | 2011-03-22 13:40:03 +0100 |
commit | 6d0bfb695277b6e137246643f259df1a1485d83d (patch) | |
tree | 3afb5bba0794791d8b95a07186d615c715b595e7 | |
parent | e6aee1612bc1be3a88a233cf1a916e4c1f97b96d (diff) | |
parent | aad4800e0df93e82a34a2d5e7fd826dc8739527a (diff) |
Merge branch 'master' of gitorious.org:pytimechart/pytimechart
-rw-r--r-- | timechart/colors.py | 9 | ||||
-rw-r--r-- | timechart/model.py | 66 | ||||
-rw-r--r-- | timechart/plugins/cpuidle.py | 77 | ||||
-rw-r--r-- | timechart/plugins/menu_select.py | 2 | ||||
-rw-r--r-- | timechart/plugins/runtime_pm.py | 2 |
5 files changed, 88 insertions, 68 deletions
diff --git a/timechart/colors.py b/timechart/colors.py index e41a226..c8cb7f8 100644 --- a/timechart/colors.py +++ b/timechart/colors.py @@ -14,15 +14,6 @@ event_bg kernel_process_bg #F0F5A3 user_process_bg #E1DFFF selected_bg #ACD7E6 -C0 #000000 -C1 #bbbbff -C2 #7777ff -C3 #5555ff -C4 #3333ff -C5 #1111ff -C6 #0000ff -S0i3 #0011ff -S0i1 #0022ff idle #000000 waiting_for_cpu #ffff88 running #555555 diff --git a/timechart/model.py b/timechart/model.py index 31510aa..99ee223 100644 --- a/timechart/model.py +++ b/timechart/model.py @@ -14,7 +14,6 @@ import colors import numpy import sys -c_state_table = ["C0","C1","C2","C4","C6","S0i1","S0i3"] def _pretty_time(time): if time > 1000000: time = time/1000000. @@ -28,7 +27,6 @@ class tcGeneric(HasTraits): name = String start_ts = CArray end_ts = CArray - linenumbers = CArray types = CArray has_comments = Bool(True) total_time = Property(Int) @@ -200,17 +198,10 @@ class tcProject(HasTraits): def get_selection_text(self,start,end): low_line = -1 high_line = -1 - for tc in self.processes: - low_i = searchsorted(tc.end_ts,start) - high_i = searchsorted(tc.start_ts,end) - if low_i < len(tc.linenumbers): - ll = tc.linenumbers[low_i] - if low_line==-1 or low_line > ll: - low_line = ll - if high_i < len(tc.linenumbers): - hl = tc.linenumbers[high_i] - if high_line==-1 or high_line > hl: - high_line = hl + low_i = searchsorted(self.timestamps,start) + high_i = searchsorted(self.timestamps,end) + low_line = self.linenumbers[low_i] + high_line = self.linenumbers[high_i] return self.get_partial_text(self.filename, low_line, high_line) ######### generic parsing part ########## @@ -218,7 +209,7 @@ class tcProject(HasTraits): def generic_find_process(self,pid,comm,ptype): if self.tmp_process.has_key((pid,comm)): return self.tmp_process[(pid,comm)] - tmp = {'type':ptype,'comm':comm,'pid':pid,'start_ts':[],'end_ts':[],'types':[],'cpus':[],'comments':[],'linenumbers':[]} + tmp = {'type':ptype,'comm':comm,'pid':pid,'start_ts':[],'end_ts':[],'types':[],'cpus':[],'comments':[]} if not (pid==0 and comm =="swapper"): self.tmp_process[(pid,comm)] = tmp return tmp @@ -241,7 +232,6 @@ class tcProject(HasTraits): p['start_ts'].append(int(event.timestamp)) p['types'].append(colors.get_color_id("waiting_for_cpu")) p['cpus'].append(event.common_cpu) - p['linenumbers'].append(event.linenumber) p_stack.append(process) else: self.cur_process[event.common_cpu] = [process] @@ -249,7 +239,6 @@ class tcProject(HasTraits): process['start_ts'].append(event.timestamp) process['types'].append(colors.get_color_id("running")) process['cpus'].append(event.common_cpu) - process['linenumbers'].append(event.linenumber) def generic_process_end(self,process,event, build_p_stack=True): @@ -283,7 +272,6 @@ class tcProject(HasTraits): p['start_ts'].append(event.timestamp) p['types'].append(colors.get_color_id("running")) p['cpus'].append(event.common_cpu) - p['linenumbers'].append(event.linenumber) def do_event_sched_switch(self,event): prev = self.generic_find_process(event.prev_pid,event.prev_comm,"user_process") @@ -295,7 +283,6 @@ class tcProject(HasTraits): prev['start_ts'].append(event.timestamp) prev['types'].append(colors.get_color_id("waiting_for_cpu")) prev['cpus'].append(event.common_cpu) - prev['linenumbers'].append(event.linenumber) self.generic_process_start(next,event) @@ -337,38 +324,6 @@ class tcProject(HasTraits): self.generic_process_start(process,event) self.generic_process_end(process,event) - def do_event_power_frequency(self,event): - self.ensure_cpu_allocated(event.common_cpu) - if event.type==2:# p_state - tc = self.tmp_p_states[event.common_cpu] - tc['start_ts'].append(event.timestamp) - tc['linenumbers'].append(event.linenumber) - tc['types'].append(event.state) - - def do_event_power_start(self,event): - self.ensure_cpu_allocated(event.common_cpu) - if event.type==1:# c_state - tc = self.tmp_c_states[event.common_cpu] - if len(tc['start_ts'])>len(tc['end_ts']): - tc['end_ts'].append(event.timestamp) - self.missed_power_end +=1 - if self.missed_power_end < 10: - print "warning: missed power_end" - if self.missed_power_end == 10: - print "warning: missed power_end: wont warn anymore!" - tc['start_ts'].append(event.timestamp) - tc['types'].append(colors.get_color_id(c_state_table[int(event.state)])) - tc['linenumbers'].append(event.linenumber) - - def do_event_power_end(self,event): - self.ensure_cpu_allocated(event.common_cpu) - - tc = self.tmp_c_states[event.common_cpu] - if len(tc['start_ts'])>len(tc['end_ts']): - tc['end_ts'].append(event.timestamp) - - - def do_function_default(self,event): process = self.generic_find_process(0,"kernel function:%s"%(event.callee),"function") self.generic_process_start(process,event) @@ -388,6 +343,8 @@ class tcProject(HasTraits): self.tmp_c_states = [] self.tmp_p_states = [] self.tmp_process = {} + self.timestamps = [] + self.linenumbers = [] self.cur_process_by_pid = {} self.wake_events = [] self.cur_process = [None]*20 @@ -423,7 +380,6 @@ class tcProject(HasTraits): t.start_ts = numpy.array(tc['start_ts']) t.end_ts = numpy.array(tc['end_ts']) t.types = numpy.array(tc['types']) - t.linenumbers = numpy.array(tc['linenumbers']) c_states.append(t) i+=1 self.c_states=c_states @@ -434,7 +390,6 @@ class tcProject(HasTraits): t.start_ts = numpy.array(tc['start_ts']) t.end_ts = numpy.array(tc['end_ts']) t.types = numpy.array(tc['types']) - t.linenumbers = numpy.array(tc['linenumbers']) i+=1 p_states.append(t) self.wake_events = numpy.array(self.wake_events,dtype=[('waker',tuple),('wakee',tuple),('time','uint64')]) @@ -459,7 +414,6 @@ class tcProject(HasTraits): t.types = numpy.array(tc['types']) t.cpus = numpy.array(tc['cpus']) t.comments = tc['comments'] #numpy.array(tc['comments']) - t.linenumbers = numpy.array(tc['linenumbers']) t.process_type = tc["type"] processes.append(t) def cmp_process(x,y): @@ -488,12 +442,14 @@ class tcProject(HasTraits): def ensure_cpu_allocated(self,cpu): # ensure we have enough per_cpu p/c_states timecharts while len(self.tmp_c_states)<=cpu: - self.tmp_c_states.append({'start_ts':[],'end_ts':[],'types':[],'linenumbers':[]}) + self.tmp_c_states.append({'start_ts':[],'end_ts':[],'types':[]}) while len(self.tmp_p_states)<=cpu: - self.tmp_p_states.append({'start_ts':[],'end_ts':[],'types':[],'linenumbers':[]}) + self.tmp_p_states.append({'start_ts':[],'end_ts':[],'types':[]}) def handle_trace_event(self,event): callback = "do_event_"+event.event + self.linenumbers.append(event.linenumber) + self.timestamps.append(event.timestamp) if event.event=='function': callback = "do_event_"+event.callee if self.plugin_methods.has_key(callback): diff --git a/timechart/plugins/cpuidle.py b/timechart/plugins/cpuidle.py new file mode 100644 index 0000000..bfddc13 --- /dev/null +++ b/timechart/plugins/cpuidle.py @@ -0,0 +1,77 @@ +from timechart.plugin import * +from timechart import colors +from timechart.model import tcProcess + +c_state_table = ["C0","C1","C2","C4","C6","S0i1","S0i3"] + +class cpu_idle(plugin): + additional_colors = """ +C0 #000000 +C1 #bbbbff +C2 #7777ff +C3 #5555ff +C4 #3333ff +C5 #1111ff +C6 #0000ff +S0i3 #0011ff +S0i1 #0022ff +""" + additional_ftrace_parsers = [ + ('cpu_idle', 'state=%d cpu_id=%d', 'state', 'cpuid'), + ] + + additional_process_types = { + } + + # stable event support + @staticmethod + def do_event_cpu_idle(self,event): + self.ensure_cpu_allocated(event.cpuid) + tc = self.tmp_c_states[event.cpuid] + if event.state != 4294967295 : + if len(tc['start_ts'])>len(tc['end_ts']): + tc['end_ts'].append(event.timestamp) + self.missed_power_end +=1 + if self.missed_power_end < 10: + print "warning: missed cpu_idle end" + if self.missed_power_end == 10: + print "warning: missed cpu_idle end: wont warn anymore!" + tc['start_ts'].append(event.timestamp) + tc['types'].append(colors.get_color_id(c_state_table[int(event.state)])) + else : + if len(tc['start_ts'])>len(tc['end_ts']): + tc['end_ts'].append(event.timestamp) + # legacy event support + @staticmethod + def do_event_power_start(self,event): + self.ensure_cpu_allocated(event.common_cpu) + if event.type==1:# c_state + tc = self.tmp_c_states[event.common_cpu] + if len(tc['start_ts'])>len(tc['end_ts']): + tc['end_ts'].append(event.timestamp) + self.missed_power_end +=1 + if self.missed_power_end < 10: + print "warning: missed power_end" + if self.missed_power_end == 10: + print "warning: missed power_end: wont warn anymore!" + tc['start_ts'].append(event.timestamp) + tc['types'].append(colors.get_color_id(c_state_table[int(event.state)])) + + @staticmethod + def do_event_power_end(self,event): + self.ensure_cpu_allocated(event.common_cpu) + + tc = self.tmp_c_states[event.common_cpu] + if len(tc['start_ts'])>len(tc['end_ts']): + tc['end_ts'].append(event.timestamp) + + @staticmethod + def do_event_power_frequency(self,event): + self.ensure_cpu_allocated(event.common_cpu) + if event.type==2:# p_state + tc = self.tmp_p_states[event.common_cpu] + tc['start_ts'].append(event.timestamp) + tc['types'].append(event.state) + +plugin_register(cpu_idle) + diff --git a/timechart/plugins/menu_select.py b/timechart/plugins/menu_select.py index 1863ffb..4518a10 100644 --- a/timechart/plugins/menu_select.py +++ b/timechart/plugins/menu_select.py @@ -32,14 +32,12 @@ menu_select #ee0000 p['end_ts'].append(int(event.timestamp+event.predicted)) p['types'].append(colors.get_color_id("menu_select")) p['cpus'].append(event.common_cpu) - p['linenumbers'].append(event.linenumber) p = p2 p['start_ts'].append(int(event.timestamp)) p['end_ts'].append(int(event.timestamp+event.expected)) p['types'].append(colors.get_color_id("menu_select")) p['cpus'].append(event.common_cpu) - p['linenumbers'].append(event.linenumber) plugin_register(menu_select) menu_select_patch=""" diff --git a/timechart/plugins/runtime_pm.py b/timechart/plugins/runtime_pm.py index f4826bb..60b7d09 100644 --- a/timechart/plugins/runtime_pm.py +++ b/timechart/plugins/runtime_pm.py @@ -41,7 +41,6 @@ rpm_active #ee0000 p['start_ts'].append(int(event.timestamp)) p['types'].append(colors.get_color_id("rpm_%s"%(event.status.lower()))) p['cpus'].append(event.common_cpu) - p['linenumbers'].append(event.linenumber) @staticmethod def do_event_runtime_pm_usage(proj, event): @@ -57,6 +56,5 @@ rpm_active #ee0000 usagecolor = 6 p['types'].append(colors.get_color_id("rpm_usage=%d"%(usagecolor))) p['cpus'].append(event.common_cpu) - p['linenumbers'].append(event.linenumber) plugin_register(runtime_pm) |