Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: tools/turbolizer/perf-turbo.py

Issue 2174803002: [turbolizer] Add support for showing perf profiling information. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [turbolizer] Add support for showing perf profiling information. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/turbolizer/index.html ('k') | tools/turbolizer/turbo-visualizer.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/turbolizer/perf-turbo.py
diff --git a/tools/turbolizer/perf-turbo.py b/tools/turbolizer/perf-turbo.py
new file mode 100644
index 0000000000000000000000000000000000000000..c90a1174d48769f7a544cb18d70977b4448f9588
--- /dev/null
+++ b/tools/turbolizer/perf-turbo.py
@@ -0,0 +1,56 @@
+# Copyright 2016 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+import json
+import re
+import argparse
+
+sys.path.append(os.environ['PERF_EXEC_PATH'] + \
+ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
+
+from perf_trace_context import *
+from Core import *
+
+def trace_begin():
+ json_obj['eventCounts'] = {}
+ prog = re.compile(r'0x[0-9a-fA-F]+')
+ for phase in reversed(json_obj['phases']):
+ if phase['name'] == "disassembly":
+ for line in phase['data'].splitlines():
+ result = re.match(prog, line)
+ if result:
+ known_addrs.add(result.group(0))
+
+def trace_end():
+ print json.dumps(json_obj)
+
+def process_event(param_dict):
+ addr = "0x%x" % int(param_dict['sample']['ip'])
+
+ # Only count samples that belong to the function
+ if addr not in known_addrs:
+ return
+
+ ev_name = param_dict['ev_name']
+ if ev_name not in json_obj['eventCounts']:
+ json_obj['eventCounts'][ev_name] = {}
+ if addr not in json_obj['eventCounts'][ev_name]:
+ json_obj['eventCounts'][ev_name][addr] = 0
+ json_obj['eventCounts'][ev_name][addr] += 1
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(
+ description="Perf script to merge profiling data with turbofan compiler "
+ "traces.")
+ parser.add_argument("file_name", metavar="JSON File",
+ help="turbo trace json file.")
+
+ args = parser.parse_args()
+
+ with open(args.file_name, 'r') as json_file:
+ json_obj = json.load(json_file)
+
+ known_addrs = set()
« no previous file with comments | « tools/turbolizer/index.html ('k') | tools/turbolizer/turbo-visualizer.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698