summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hansen <markhansen@google.com>2023-11-27 11:15:50 +1100
committerMark Hansen <markhansen@google.com>2023-11-27 11:16:23 +1100
commit8734af1c56b3f683a2a400d8eff46ba833ed3f38 (patch)
tree6b1a2b2dc547768fe6dd7b6f215b1c5e30e6bd14
parentce9bf3fa199283c568dd82a0ddddff15adcfbc84 (diff)
downloadextras-8734af1c56b3f683a2a400d8eff46ba833ed3f38.tar.gz
Fill in pprof time_nanos from profile timestamp
So when you open a profile with pprof, it gives you the time the profile was taken: ``` $ pprof pprof.profile ... Time: Jan 18, 2018 at 8:45pm (AEDT) ``` BUG: 202799418 Change-Id: I9953b7f42cc587af4efc95ae3ec7161b9f2173d8
-rwxr-xr-xsimpleperf/scripts/pprof_proto_generator.py2
-rw-r--r--simpleperf/scripts/test/pprof_proto_generator_test.py4
2 files changed, 6 insertions, 0 deletions
diff --git a/simpleperf/scripts/pprof_proto_generator.py b/simpleperf/scripts/pprof_proto_generator.py
index b2ca0901..a9418105 100755
--- a/simpleperf/scripts/pprof_proto_generator.py
+++ b/simpleperf/scripts/pprof_proto_generator.py
@@ -315,6 +315,8 @@ class PprofProfileGenerator(object):
comments.append("App Version Code:\n" + meta_info["app_versioncode"])
for comment in comments:
self.profile.comment.append(self.get_string_id(comment))
+ if "timestamp" in meta_info:
+ self.profile.time_nanos = int(meta_info["timestamp"]) * 1000 * 1000 * 1000
numbers_re = re.compile(r"\d+")
diff --git a/simpleperf/scripts/test/pprof_proto_generator_test.py b/simpleperf/scripts/test/pprof_proto_generator_test.py
index 297cf149..d72f75f5 100644
--- a/simpleperf/scripts/test/pprof_proto_generator_test.py
+++ b/simpleperf/scripts/test/pprof_proto_generator_test.py
@@ -96,6 +96,10 @@ class TestPprofProtoGenerator(TestBase):
""" Test the build ids generated are not padded with zeros. """
self.assertIn('build_id: e3e938cc9e40de2cfe1a5ac7595897de(', self.run_generator())
+ def test_time_nanos(self):
+ """ Test the timestamp is adjusted to be nanoseconds. """
+ self.assertIn('time_nanos: 1516268753000000000\n', self.run_generator())
+
def test_build_id_with_binary_cache(self):
""" Test the build ids for elf files in binary_cache are not padded with zero. """
# Test with binary_cache.