diff options
author | KP Singh <kpsingh@google.com> | 2017-06-21 21:11:13 +0200 |
---|---|---|
committer | KP Singh <kpsingh@google.com> | 2017-06-21 21:11:13 +0200 |
commit | 16ad8df451f9280ba91f3bc03f91c781b4f4596a (patch) | |
tree | af60f4d81e200e44aa28d357087f771d78107a19 | |
parent | 5a8aec8eb8f5b6c950587dc1c4c0eddb85cdd7cb (diff) | |
parent | 8dcd96197ec48f37615d3ae7c6465e41f4ca6e3f (diff) | |
download | trappy-16ad8df451f9280ba91f3bc03f91c781b4f4596a.tar.gz |
Merge branch 'derkling-add-ns-clock-support'
-rw-r--r-- | tests/test_base.py | 12 | ||||
-rw-r--r-- | trappy/ftrace.py | 9 |
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_base.py b/tests/test_base.py index 96b8d96..a0a4920 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -101,6 +101,7 @@ class TestBase(utils_tests.SetupDirectory): """TestBase: Task name, PID, CPU and timestamp are properly paresed """ events = { + # Trace events using [global] clock format ([us] resolution) 1001.456789 : { 'task': 'rcu_preempt', 'pid': 1123, 'cpu': 001 }, 1002.456789 : { 'task': 'rs:main', 'pid': 2123, 'cpu': 002 }, 1003.456789 : { 'task': 'AsyncTask #1', 'pid': 3123, 'cpu': 003 }, @@ -109,6 +110,15 @@ class TestBase(utils_tests.SetupDirectory): 1006.456789 : { 'task': 'IntentService[', 'pid': 6123, 'cpu': 005 }, 1006.456789 : { 'task': r'/system/bin/.s$_?.u- \a]}c\./ef[.12]*[[l]in]ger', 'pid': 1234, 'cpu': 666 }, + # Trace events using [boot] clock format ([ns] resolution) + 1011456789000: { 'task': 'rcu_preempt', 'pid': 1123, 'cpu': 001 }, + 1012456789000: { 'task': 'rs:main', 'pid': 2123, 'cpu': 002 }, + 1013456789000: { 'task': 'AsyncTask #1', 'pid': 3123, 'cpu': 003 }, + 1014456789000: { 'task': 'kworker/1:1H', 'pid': 4123, 'cpu': 004 }, + 1015456789000: { 'task': 'jbd2/sda2-8', 'pid': 5123, 'cpu': 005 }, + 1016456789000: { 'task': 'IntentService[', 'pid': 6123, 'cpu': 005 }, + 1016456789000: { 'task': r'/system/bin/.s$_?.u- \a]}c\./ef[.12]*[[l]in]ger', + 'pid': 1234, 'cpu': 666 }, } in_data = """""" @@ -133,6 +143,8 @@ class TestBase(utils_tests.SetupDirectory): self.assertEquals(set(dfr.columns), expected_columns) for timestamp, event in events.iteritems(): + if type(timestamp) == int: + timestamp = float(timestamp) / 1e9 self.assertEquals(dfr["__comm"].loc[timestamp], event['task']) self.assertEquals(dfr["__pid"].loc[timestamp], event['pid']) self.assertEquals(dfr["__cpu"].loc[timestamp], event['cpu']) diff --git a/trappy/ftrace.py b/trappy/ftrace.py index 23189d1..213a870 100644 --- a/trappy/ftrace.py +++ b/trappy/ftrace.py @@ -49,7 +49,7 @@ def _plot_freq_hists(allfreqs, what, axis, title): SPECIAL_FIELDS_RE = re.compile( r"^\s*(?P<comm>.*)-(?P<pid>\d+)(?:\s+\(.*\))"\ r"?\s+\[(?P<cpu>\d+)\](?:\s+....)?\s+"\ - r"(?P<timestamp>[0-9]+\.[0-9]+): (\w+:\s+)+(?P<data>.+)" + r"(?P<timestamp>[0-9]+(?P<us>\.[0-9]+)?): (\w+:\s+)+(?P<data>.+)" ) class GenericFTrace(BareTrace): @@ -199,7 +199,14 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace.""" comm = fields_match.group('comm') pid = int(fields_match.group('pid')) cpu = int(fields_match.group('cpu')) + + # The timestamp, depending on the trace_clock configuration, can be + # reported either in [s].[us] or [ns] format. Let's ensure that we + # always generate DF which have the index expressed in: + # [s].[decimals] timestamp = float(fields_match.group('timestamp')) + if not fields_match.group('us'): + timestamp /= 1e9 data_str = fields_match.group('data') if not self.basetime: |