diff options
-rw-r--r-- | tests/test_systrace.py | 4 | ||||
-rw-r--r-- | tests/trace_systrace.html | 4 | ||||
-rw-r--r-- | trappy/sched.py | 19 |
3 files changed, 24 insertions, 3 deletions
diff --git a/tests/test_systrace.py b/tests/test_systrace.py index 22b9288..4c2a594 100644 --- a/tests/test_systrace.py +++ b/tests/test_systrace.py @@ -31,6 +31,10 @@ class TestSystrace(utils_tests.SetupDirectory): events = ["sched_switch", "sched_wakeup", "trace_event_clock_sync"] trace = trappy.SysTrace("trace.html", events=events) + self.assertTrue(hasattr(trace, "sched_switch")) + self.assertEquals(len(trace.sched_switch.data_frame), 4) + self.assertTrue("prev_comm" in trace.sched_switch.data_frame.columns) + self.assertTrue(hasattr(trace, "sched_wakeup")) self.assertEquals(len(trace.sched_wakeup.data_frame), 4) self.assertTrue("target_cpu" in trace.sched_wakeup.data_frame.columns) diff --git a/tests/trace_systrace.html b/tests/trace_systrace.html index d35e904..94f2aaa 100644 --- a/tests/trace_systrace.html +++ b/tests/trace_systrace.html @@ -25,9 +25,13 @@ # | | | | |||| | | RenderThread-1143 ( 611) [004] ...1 514769.085985: tracing_mark_write: E com.android.systemui-611 ( 611) [001] d..5 514769.086090: sched_wakeup: comm=Binder_5 pid=679 prio=120 success=1 target_cpu=001 state=W +com.android.systemui-611 ( 611) [001] d..3 514769.086139: sched_switch: prev_comm=ndroid.systemui prev_pid=611 prev_prio=120 prev_state=S ==> next_comm=Binder_5 next_pid=679 next_prio=120 atrace-15227 (15227) [000] ...1 514769.086243: tracing_mark_write: trace_event_clock_sync: realtime_ts=1448979311493 +atrace-15227 (15227) [000] d..3 514769.086283: sched_switch: prev_comm=atrace prev_pid=15227 prev_prio=120 prev_state=S ==> next_comm=Binder_4 next_pid=280 next_prio=120 Binder_4-280 ( 184) [000] d..5 514769.086330: sched_wakeup: comm=Binder_5 pid=1158 prio=120 success=1 target_cpu=002 state=W + <idle>-0 (-----) [002] d..3 514769.086339: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Binder_5 next_pid=1158 next_prio=120 Binder_4-280 ( 184) [000] d..3 514769.086417: sched_wakeup: comm=Binder_5 pid=1158 prio=120 success=1 target_cpu=002 state=W|m + <idle>-0 (-----) [002] d..3 514769.086424: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=Binder_5 next_pid=1158 next_prio=120 Binder_4-280 ( 184) [000] d..4 514769.086473: sched_wakeup: comm=EventThread pid=238 prio=111 success=1 target_cpu=003 state=W </script> <!-- END TRACE --> diff --git a/trappy/sched.py b/trappy/sched.py index ca00268..693be99 100644 --- a/trappy/sched.py +++ b/trappy/sched.py @@ -98,11 +98,24 @@ SchedWakeupNew = register_dynamic_ftrace("SchedWakeupNew", "sched_wakeup_new:", "sched", parse_raw=True) """Register SchedWakeupNew Event""" -SchedSwitch = register_dynamic_ftrace("SchedSwitch", "sched_switch", "sched", - parse_raw=True) -"""Register SchedSwitch Event""" # pylint: enable=invalid-name +class SchedSwitch(Base): + """Parse sched_switch""" + + unique_word = "sched_switch:" + + def __init__(self): + super(SchedSwitch, self).__init__(parse_raw=True) + + def create_dataframe(self): + self.data_array = [line.replace(" ==> ", " ", 1) + for line in self.data_array] + + super(SchedSwitch, self).create_dataframe() + +register_ftrace_parser(SchedSwitch, "sched") + class SchedCpuFrequency(Base): """Corresponds to Linux kernel trace event power/cpu_frequency""" |