Index: tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf_to_tracing.py |
diff --git a/tools/profile_chrome/third_party/perf_to_tracing.py b/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf_to_tracing.py |
similarity index 70% |
copy from tools/profile_chrome/third_party/perf_to_tracing.py |
copy to tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf_to_tracing.py |
index 280937a8f49b85322138931ad035bb7aebf44fea..2a74b1663facb5407938359de04516d96cf29133 100644 |
--- a/tools/profile_chrome/third_party/perf_to_tracing.py |
+++ b/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf_to_tracing.py |
@@ -1,75 +1,73 @@ |
-# Script for converting perf script events into tracing JSON. |
-# |
-# Generated by perf script -g python |
+# perf script event handlers, generated by perf script -g python |
# Licensed under the terms of the GNU GPL License version 2 |
-import json |
+# The common_* event handler fields are the most useful fields common to |
+# all events. They don't necessarily correspond to the 'common_*' fields |
+# in the format files. Those fields not available as handler params can |
+# be retrieved using Python functions of the form common_*(context). |
+# See the perf-trace-python Documentation for the list of available functions. |
+ |
import os |
import sys |
- |
+import json |
from collections import deque |
- |
# Categorize DSOs by component. |
-dso_to_comp = { |
- 'libdvm.so': 'Java', |
- 'libart.so': 'Java', |
- 'libjavacore.so': 'Java', |
- 'libandroid_runtime.so': 'Android', |
- 'libgui.so': 'Android', |
- 'libui.so': 'Android', |
- 'libbinder.so': 'Android', |
- 'libmemalloc.so': 'Android', |
- 'libcrypto.so': 'Android', |
- 'libcutils.so':'Android', |
- 'libutils.so': 'Android', |
- '[kernel.kallsyms]': 'Kernel', |
- 'libc.so': 'Standard Lib', |
- 'libstdc++.so': 'Standard Lib', |
- 'libm.so':'Standard Lib', |
- 'libGLESv2_adreno.so': 'GPU Driver', |
- 'libGLESv2_adreno200.so': 'GPU Driver', |
- 'libq3dtools_adreno200.so': 'GPU Driver', |
- 'libEGL_adreno.so': 'GPU Driver', |
- 'libEGL_adreno200.so': 'GPU Driver', |
- 'libEGL.so': 'GPU Driver', |
- 'libgsl.so': 'GPU Driver', |
- 'libGLESv2.so': 'GPU Driver', |
- 'libsc-a3xx.so': 'GPU Driver', |
- 'libadreno_utils.so': 'GPU Driver', |
- 'eglsubAndroid.so': 'GPU Driver', |
- 'gralloc.msm8960.so': 'GPU Driver', |
- 'libadreno_utils': 'GPU Driver', |
- 'libGLES_mali.so': 'GPU Driver', |
- 'libchromeview.so': 'Chrome', |
- '[unknown]': '<unknown>', |
- '[UNKNOWN]': '<unknown>', |
-} |
- |
+dso_to_comp = {'libdvm.so': 'Java', |
+ 'libart.so': 'Java', |
+ 'libjavacore.so': 'Java', |
+ 'libandroid_runtime.so': 'Android', |
+ 'libgui.so': 'Android', |
+ 'libui.so': 'Android', |
+ 'libbinder.so': 'Android', |
+ 'libmemalloc.so': 'Android', |
+ 'libcrypto.so': 'Android', |
+ 'libcutils.so':'Android', |
+ 'libutils.so': 'Android', |
+ '[kernel.kallsyms]': 'Kernel', |
+ 'libc.so': 'Standard Lib', |
+ 'libstdc++.so': 'Standard Lib', |
+ 'libm.so':'Standard Lib', |
+ 'libGLESv2_adreno.so': 'GPU Driver', |
+ 'libGLESv2_adreno200.so': 'GPU Driver', |
+ 'libq3dtools_adreno200.so': 'GPU Driver', |
+ 'libEGL_adreno.so': 'GPU Driver', |
+ 'libEGL_adreno200.so': 'GPU Driver', |
+ 'libEGL.so': 'GPU Driver', |
+ 'libgsl.so': 'GPU Driver', |
+ 'libGLESv2.so': 'GPU Driver', |
+ 'libsc-a3xx.so': 'GPU Driver', |
+ 'libadreno_utils.so': 'GPU Driver', |
+ 'eglsubAndroid.so': 'GPU Driver', |
+ 'gralloc.msm8960.so': 'GPU Driver', |
+ 'libadreno_utils': 'GPU Driver', |
+ 'libGLES_mali.so': 'GPU Driver', |
+ 'libchromeview.so': 'Chrome', |
+ '[unknown]': '<unknown>', |
+ '[UNKNOWN]': '<unknown>', |
+ } |
def FilterSymbolModule(module): |
m = dso_to_comp.get(module, None) |
if m: |
return m |
- if module.find('libchrome.') == 0: |
+ if module.find('libchrome') == 0 or module.find('libcontent_shell') == 0: |
return 'Chrome' |
if module.find('dalvik') >= 0 or module.find('@') >= 0: |
return 'Java' |
return module |
- |
def FilterSymbolName(module, orign_module, name): |
if module == 'Java': |
- return name |
+ return name #orign_module |
elif module == 'GPU Driver': |
- return name |
+ return name # orign_module |
if name == '': |
return orign_module + ':unknown' |
if name[0].isdigit() or name == '(nil)': |
return orign_module + ':unknown' |
return name |
- |
class StackFrameNode: |
def __init__(self, stack_id, name, category): |
self.stack_id = stack_id |
@@ -108,7 +106,6 @@ class StackFrameNode: |
self.have_total_weight = True |
return self.total_weight |
- |
class PerfSample: |
def __init__(self, stack_id, ts, cpu, tid, weight, samp_type, comm): |
self.stack_id = stack_id |
@@ -132,20 +129,20 @@ class PerfSample: |
ret['sf'] = self.stack_id # Stack frame id |
return ret |
- |
samples = [] |
root_chain = StackFrameNode(0, 'root', '[unknown]') |
next_stack_id = 1 |
tot_period = 0 |
saved_period = 0 |
- |
def process_event(param_dict): |
global next_stack_id |
global saved_period |
global tot_period |
+ #print "process_event", param_dict |
samp_comm = param_dict['comm'] |
+ #samp_pid = param_dict['pid'] |
samp_tid = param_dict['tid'] |
samp_cpu = param_dict['cpu'] |
samp_ts = param_dict['time'] |
@@ -200,12 +197,13 @@ def process_event(param_dict): |
stack_frame.samples.append(sample) |
saved_period += samp_period |
- |
def trace_begin(): |
pass |
- |
def trace_end(): |
+ #print '// tot_period', tot_period |
+ #print '// saved_period', saved_period |
+ |
# Return siblings of a call tree node. |
def GetNodeSiblings(node): |
if not node: |
@@ -214,7 +212,7 @@ def trace_end(): |
return [] |
return node.parent.children.values() |
- # Try to reduce misplaced stack leaves by moving them up into sibling nodes. |
+ # Try to reduce misplaced stack leaves by mobing them up into sibling nodes. |
def FixCallTree(node, parent): |
# Get siblings of node's parent. |
node.parent = parent |