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

Unified Diff: systrace/systrace/output_generator.py

Issue 2712163002: [Systrace] Fix systrace clock syncing issue with BattOr. (Closed)
Patch Set: no more telemetry references Created 3 years, 9 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
Index: systrace/systrace/output_generator.py
diff --git a/systrace/systrace/output_generator.py b/systrace/systrace/output_generator.py
index f0ff06aa156a8aa8286cb5d560ac0ed10ee0df6c..45b16c246e5cc1cb7086f5e605345452054d8f02 100644
--- a/systrace/systrace/output_generator.py
+++ b/systrace/systrace/output_generator.py
@@ -12,6 +12,7 @@ import StringIO
from systrace import tracing_controller
from systrace import trace_result
+from tracing.trace_data import trace_data
# TODO(alexandermont): Current version of trace viewer does not support
@@ -20,6 +21,21 @@ from systrace import trace_result
# trace viewer is working again.
OUTPUT_CONTROLLER_TRACE_ = False
CONTROLLER_TRACE_DATA_KEY = 'controllerTraceDataKey'
+_SYSTRACE_TO_TRACE_DATA_NAME_MAPPING = {
+ 'systemTraceEvents': trace_data.ATRACE_PART,
+ 'powerTraceAsString': trace_data.BATTOR_TRACE_PART,
+ 'systraceController': trace_data.TELEMETRY_PART,
+ 'traceEvents': trace_data.CHROME_TRACE_PART,
+}
+
+
+def NewGenerateHTMLOutput(trace_results, output_file_name):
+ trace_data_builder = trace_data.TraceDataBuilder()
+ for trace in trace_results:
+ trace_data_part = _SYSTRACE_TO_TRACE_DATA_NAME_MAPPING.get(
+ trace.source_name)
+ trace_data_builder.AddTraceFor(trace_data_part, trace.raw_data)
+ trace_data_builder.AsData().Serialize(output_file_name, 'Systrace')
charliea (OOO until 10-5) 2017/03/21 19:47:23 'Systrace' should probably be a constant
rnephew (Reviews Here) 2017/03/23 15:14:15 Done.
def GenerateHTMLOutput(trace_results, output_file_name):
@@ -33,6 +49,11 @@ def GenerateHTMLOutput(trace_results, output_file_name):
def _ReadAsset(src_dir, filename):
return open(os.path.join(src_dir, filename)).read()
+ # The old method does not support anything except atrace.
charliea (OOO until 10-5) 2017/03/20 14:37:38 ccraik@chromium.org, now that the output generator
Chris Craik 2017/03/20 17:38:37 I agree it's gross, but I really don't want to bre
charliea (OOO until 10-5) 2017/03/21 19:47:23 Randy, could you add a TODO describing why we have
charliea (OOO until 10-5) 2017/03/21 19:47:23 Decision based on VC: we'll maintain the dual path
rnephew (Reviews Here) 2017/03/23 15:14:15 Added comment about removing once java no longer u
+ if len(trace_results) > 2:
Chris Craik 2017/03/21 19:52:23 The comment above makes it sound like we should be
rnephew (Reviews Here) 2017/03/23 15:14:15 It should work with any single trace. I reworded i
+ NewGenerateHTMLOutput(trace_results, output_file_name)
+ return os.path.abspath(output_file_name)
+
systrace_dir = os.path.abspath(os.path.dirname(__file__))
try:
@@ -63,9 +84,6 @@ def GenerateHTMLOutput(trace_results, output_file_name):
# for each tracing agent (including the controller tracing agent).
html_file.write('<!-- BEGIN TRACE -->\n')
for result in trace_results:
- if (result.source_name == tracing_controller.TRACE_DATA_CONTROLLER_NAME and
- not OUTPUT_CONTROLLER_TRACE_):
- continue
html_file.write(' <script class="trace-data" type="application/text">\n')
html_file.write(_ConvertToHtmlString(result.raw_data))
html_file.write(' </script>\n')
@@ -102,8 +120,6 @@ def GenerateJSONOutput(trace_results, output_file_name):
results = _ConvertTraceListToDictionary(trace_results)
results[CONTROLLER_TRACE_DATA_KEY] = (
tracing_controller.TRACE_DATA_CONTROLLER_NAME)
- if not OUTPUT_CONTROLLER_TRACE_:
- results[tracing_controller.TRACE_DATA_CONTROLLER_NAME] = []
with open(output_file_name, 'w') as json_file:
json.dump(results, json_file)
final_path = os.path.abspath(output_file_name)

Powered by Google App Engine
This is Rietveld 408576698