diff options
author | Mark Hansen <markhansen@google.com> | 2021-10-19 14:21:24 +1100 |
---|---|---|
committer | Mark Hansen <markhansen@google.com> | 2021-10-19 03:24:34 +0000 |
commit | dcd480945625484b9edf525ed6f61b22a938d9c9 (patch) | |
tree | 34b349a351adf7f8ca68105c2ff127e53efb458c | |
parent | 82ead95fc241da63f2077ce1bfcc7abb42c432d9 (diff) | |
download | extras-dcd480945625484b9edf525ed6f61b22a938d9c9.tar.gz |
Add comments to pprof_proto_generator
These show up in some pprof viewers.
There's still a bunch more metadata we could add in here, but this is a decent start.
BUG=202799418
Change-Id: Ia59fa120de7d2f14cefd58820587e7eda6e7f0ef
Test: Ran test/test.py -p TestPprofProtoGenerator.\*
-rwxr-xr-x | simpleperf/scripts/pprof_proto_generator.py | 10 | ||||
-rw-r--r-- | simpleperf/scripts/test/pprof_proto_generator_test.py | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/simpleperf/scripts/pprof_proto_generator.py b/simpleperf/scripts/pprof_proto_generator.py index a002f897..f49f6315 100755 --- a/simpleperf/scripts/pprof_proto_generator.py +++ b/simpleperf/scripts/pprof_proto_generator.py @@ -28,6 +28,7 @@ import logging import os import os.path import re +import sys from simpleperf_report_lib import ReportLib from simpleperf_utils import (Addr2Nearestline, BaseArgumentParser, BinaryFinder, extant_dir, @@ -311,6 +312,15 @@ class PprofProfileGenerator(object): self.lib.ShowArtFrames() for file_path in self.config['proguard_mapping_file'] or []: self.lib.AddProguardMappingFile(file_path) + + comments = [ + "Simpleperf Record Command:\n" + self.lib.GetRecordCmd(), + "Converted to pprof with:\n" + " ".join(sys.argv), + "Architecture:\n" + self.lib.GetArch(), + ] + for comment in comments: + self.profile.comment.append(self.get_string_id(comment)) + numbers_re = re.compile(r"\d+") # Process all samples in perf.data, aggregate samples. diff --git a/simpleperf/scripts/test/pprof_proto_generator_test.py b/simpleperf/scripts/test/pprof_proto_generator_test.py index f9e2680c..c53cabbd 100644 --- a/simpleperf/scripts/test/pprof_proto_generator_test.py +++ b/simpleperf/scripts/test/pprof_proto_generator_test.py @@ -229,3 +229,13 @@ class TestPprofProtoGenerator(TestBase): self.assertNotEqual(function.source_filename_id, 0) source_filename = generator.get_string(function.source_filename_id) self.assertIn('two_functions.cpp', source_filename) + + def test_comments(self): + profile = self.generate_profile(None, ['perf_with_interpreter_frames.data']) + comments = "\n".join([profile.string_table[i] for i in profile.comment]) + self.assertIn('Simpleperf Record Command:\n/data/data/com.google.sample.tunnel/simpleperf record --in-app --tracepoint-events /data/local/tmp/tracepoint_events --app com.google.sample.tunnel -g --no-post-unwind --duration 30', comments) + self.assertIn('Converted to pprof with:', comments) + # The full path changes per-machine, so only assert on a subset of the + # path. + self.assertIn('testdata/perf_with_interpreter_frames.data', comments) + self.assertIn('Architecture:\naarch64', comments) |