summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/tracing/bin
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/tracing/bin')
-rw-r--r--chromium/third_party/catapult/tracing/bin/PRESUBMIT.py19
-rw-r--r--chromium/third_party/catapult/tracing/bin/README.md42
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/add_reserved_diagnostics94
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/chartjson2histograms.py38
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/compare_samples51
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/generate_about_tracing_contents14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/histograms2csv40
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/histograms2html56
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/html2trace53
-rw-r--r--chromium/third_party/catapult/tracing/bin/index.html115
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/label_histograms56
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/map_traces14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/memory_infra_remote_dump131
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/merge_histograms32
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/merge_traces14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/results2json36
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/run_dev_server_tests14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/run_metric76
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/run_node_tests23
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/run_py_tests46
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/run_symbolizer_tests39
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/run_tests25
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/run_vinn_tests14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/slim_trace16
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/strip_memory_infra_trace13
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/symbolize_trace17
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/trace2html14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/update_gni14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/validate_all_diagnostics112
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/validate_all_metrics43
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/vulcanize_trace_viewer14
-rwxr-xr-xchromium/third_party/catapult/tracing/bin/why_imported48
32 files changed, 1333 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/tracing/bin/PRESUBMIT.py b/chromium/third_party/catapult/tracing/bin/PRESUBMIT.py
new file mode 100644
index 00000000000..799215d729d
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/PRESUBMIT.py
@@ -0,0 +1,19 @@
+# Copyright 2015 The Chromium 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
+
+def CheckChange(input_api, output_api):
+ init_py_path = os.path.join(input_api.PresubmitLocalPath(), '__init__.py')
+ res = []
+ if os.path.exists(init_py_path):
+ res += [output_api.PresubmitError(
+ '__init__.py is not allowed to exist in bin/')]
+ return res
+
+def CheckChangeOnUpload(input_api, output_api):
+ return CheckChange(input_api, output_api)
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ return CheckChange(input_api, output_api)
diff --git a/chromium/third_party/catapult/tracing/bin/README.md b/chromium/third_party/catapult/tracing/bin/README.md
new file mode 100644
index 00000000000..fae0051fb37
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/README.md
@@ -0,0 +1,42 @@
+Quick descriptions of the scripts in tracing/bin/:
+
+ * `chartjson2histograms`: Converts a chartjson file to HistogramSet JSON.
+ * `compare_samples`: Compares metric results between two runs. Supports
+ chart-json, HistogramSet JSON, and buildbot formats.
+ * `generate_about_tracing_contents`: Vulcanizes trace viewer.
+ * `histograms2csv`: Converts HistogramSet JSON to CSV.
+ * `histograms2html`: Vulcanizes results.html. Optionally copies HistogramSet
+ JSON from existing results.html and/or histograms.json file.
+ * `html2trace`: Extracts trace JSON from a vulcanized trace HTML file.
+ * `label_histograms`: Add a label to Histograms in an HTML or JSON file.
+ * `map_traces`: Runs a trace map function over multiple traces. See also
+ `run_metric`.
+ * `memory_infra_remote_dump`: Extracts before/after memory dumps from a
+ devtools remote protocol port.
+ * `merge_histograms`: Merges Histograms from HistogramSet JSON according to a
+ sequence of grouping keys, produces a new HistogramSet JSON.
+ * `merge_traces`: Merge traces from either vulcanized HTML or JSON files to
+ either a vulcanized HTML or a JSON file.
+ * `results2json`: Extracts HistogramSet JSON from a results.html file.
+ * `run_dev_server_tests`: Automatically run tracing dev server tests.
+ * `run_metric`: Run a metric over one or more traces, produce vulcanized
+ results.html.
+ * `run_node_tests`: Automatically run headless tracing tests in node.
+ * `run_py_tests`: Automatically run tracing python tests.
+ * `run_tests`: Automatically run all tracing tests.
+ * `run_vinn_tests`: Automatically run headless tracing tests in vinn.
+ * `slim_trace`: Reads trace data from either HTML or JSON, removes some data,
+ writes a new `slimmed_$filename` file.
+ * `strip_memory_infra_trace`: Reads memory trace JSON, removes some data,
+ writes a new `$filename-filtered.json` file.
+ * `symbolize_trace`: Modifies trace JSON to symbolize symbols using a Chromium
+ Debug build output directory.
+ * `trace2html`: Vulcanizes trace data from a JSON file to an HTML file.
+ * `update_gni`: Updates `trace_viewer.gni`.
+ * `validate_all_diagnostics`: Checks that all Diagnostic classes in
+ `tracing/tracing/value/diagnostics/` are registered correctly.
+ * `validate_all_metrics`: Checks that all metric functions in
+ `tracing/tracing/metrics/` are registered correctly.
+ * `vulcanize_trace_viewer`: Vulcanizes trace viewer. (TODO(benjhayden): What is
+ the difference between this and `generate_about_tracing_contents`?)
+ * `why_imported`: Explain why given modules are imported in trace viewer.
diff --git a/chromium/third_party/catapult/tracing/bin/add_reserved_diagnostics b/chromium/third_party/catapult/tracing/bin/add_reserved_diagnostics
new file mode 100755
index 00000000000..57b835b5285
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/add_reserved_diagnostics
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium 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 argparse
+import json
+import sys
+import os
+
+tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(tracing_path)
+import tracing_project
+tracing_project.UpdateSysPathIfNeeded()
+from py_utils import camel_case
+from tracing.value.diagnostics import add_reserved_diagnostics
+from tracing.value.diagnostics import generic_set
+from tracing.value.diagnostics import reserved_infos
+
+
+LOG_URLS_CAMELCASE = camel_case.ToUnderscore(reserved_infos.LOG_URLS.name)
+LOG_URLS_K = LOG_URLS_CAMELCASE + '_k'
+LOG_URLS_V = LOG_URLS_CAMELCASE + '_v'
+
+BUILD_URLS_CAMELCASE = camel_case.ToUnderscore(reserved_infos.BUILD_URLS.name)
+BUILD_URLS_K = BUILD_URLS_CAMELCASE + '_k'
+BUILD_URLS_V = BUILD_URLS_CAMELCASE + '_v'
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Adds reserved diagnostics to a HistogramSet.',
+ add_help=False)
+ parser.add_argument('input_path',
+ help='HistogramSet JSON file path (input).')
+ parser.add_argument(
+ '--stdout',
+ action='store_true',
+ help='If present, will print the new HistogramSet instead of '
+ 'clobbering the file referenced by input_path.')
+ parser.add_argument(
+ '--output_path',
+ help='If present, will write new HistogramSet to this file instead of '
+ 'clobbering the file referenced by input_path.')
+ parser.add_argument('-h', '--help', action='help',
+ help='Show this help message and exit.')
+ arg_names_to_infos = {}
+ for info in reserved_infos.AllInfos():
+ if info.type == 'GenericSet':
+ name = camel_case.ToUnderscore(info.name)
+ arg_names_to_infos[name] = info
+ parser.add_argument('--%s' % name)
+
+ # TODO(#3770): Clean this up.
+ parser.add_argument('--%s' % LOG_URLS_K)
+ parser.add_argument('--%s' % LOG_URLS_V)
+
+ parser.add_argument('--%s' % BUILD_URLS_K)
+ parser.add_argument('--%s' % BUILD_URLS_V)
+
+ args = parser.parse_args()
+
+ names_to_values = {}
+ for name, value in vars(args).iteritems():
+ if name == LOG_URLS_K and value is not None:
+ v_value = vars(args)[LOG_URLS_V]
+ names_to_values[reserved_infos.LOG_URLS.name] = [value, v_value]
+ continue
+ if name == BUILD_URLS_K and value is not None:
+ v_value = vars(args)[BUILD_URLS_V]
+ names_to_values[reserved_infos.BUILD_URLS.name] = [value, v_value]
+ continue
+ if name in arg_names_to_infos and value is not None:
+ diagnostic_name = arg_names_to_infos[name].name
+ ctor = arg_names_to_infos[name].entry_type
+ names_to_values[diagnostic_name] = ctor(value)
+
+ with open(args.input_path, 'r') as f:
+ dicts = json.loads(f.read())
+
+ results_json = add_reserved_diagnostics.AddReservedDiagnostics(
+ dicts, names_to_values)
+
+ if args.stdout:
+ print results_json
+ else:
+ path = args.output_path or args.input_path
+ with open(path, 'w') as f:
+ f.write(results_json)
+
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/catapult/tracing/bin/chartjson2histograms.py b/chromium/third_party/catapult/tracing/bin/chartjson2histograms.py
new file mode 100755
index 00000000000..1d8f36a641f
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/chartjson2histograms.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium 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 argparse
+import sys
+import os
+
+TRACING_PATH = os.path.abspath(
+ os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(TRACING_PATH)
+import tracing_project # pylint: disable=wrong-import-position
+tracing_project.UpdateSysPathIfNeeded()
+
+from tracing.value import convert_chart_json # pylint: disable=wrong-import-position
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Converts a chartjson file to HistogramSet JSON.',
+ add_help=False)
+ parser.add_argument('chartjson_path',
+ help='chartjson file path (input).')
+ parser.add_argument('histograms_path',
+ help='HistogramSet JSON file path (output).')
+ parser.add_argument('-h', '--help', action='help',
+ help='Show this help message and exit.')
+ args = parser.parse_args()
+ result = convert_chart_json.ConvertChartJson(args.chartjson_path)
+ if result.returncode != 0:
+ sys.stderr.write(result.stdout)
+ else:
+ file(args.histograms_path, 'w').write(result.stdout)
+ return result.returncode
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/catapult/tracing/bin/compare_samples b/chromium/third_party/catapult/tracing/bin/compare_samples
new file mode 100755
index 00000000000..0d67a997837
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/compare_samples
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import os
+import sys
+
+tracing_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
+ '..'))
+sys.path.append(tracing_path)
+from tracing.metrics import compare_samples
+
+def Main(argv):
+ parser = argparse.ArgumentParser(
+ description='Compare samples.')
+ parser.add_argument('sample_a', type=str,
+ help='comma-separated list of paths to valuesets from '
+ 'sample a')
+ parser.add_argument('sample_b', type=str,
+ help='comma-separated list of paths to valuesets from '
+ 'sample b')
+ parser.add_argument('metric', type=str,
+ help='name of the metric to compare')
+ parser.add_argument('--chartjson', dest='format', action='store_const',
+ const='chartjson',
+ help='assume chartjson format for the input data')
+ parser.add_argument('--buildbot', dest='format', action='store_const',
+ const='buildbot',
+ help='assume buildbot result line format for the data')
+ args = parser.parse_args(argv[1:])
+
+ if not args.format:
+ filename = os.path.basename(sample_a.split(',')[0])
+ args.format = 'chartjson'
+
+ vinn_result = compare_samples.CompareSamples(
+ args.sample_a,
+ args.sample_b,
+ args.metric,
+ args.format
+ )
+ stdout = vinn_result.stdout
+ if not isinstance(stdout, str):
+ stdout = stdout.decode('utf-8')
+ print(stdout)
+ return vinn_result.returncode
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/generate_about_tracing_contents b/chromium/third_party/catapult/tracing/bin/generate_about_tracing_contents
new file mode 100755
index 00000000000..feee8828976
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/generate_about_tracing_contents
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright (c) 2014 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+ sys.path.append(tracing_path)
+ from tracing_build import generate_about_tracing_contents
+ sys.exit(generate_about_tracing_contents.Main(sys.argv[1:]))
diff --git a/chromium/third_party/catapult/tracing/bin/histograms2csv b/chromium/third_party/catapult/tracing/bin/histograms2csv
new file mode 100755
index 00000000000..c36246ec3d2
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/histograms2csv
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import codecs
+import json
+import sys
+import os
+
+tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(tracing_path)
+import tracing_project
+tracing_project.UpdateSysPathIfNeeded()
+
+from tracing.value import histograms_to_csv
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Convert HistogramSet JSON to CSV.',
+ add_help=False)
+ parser.add_argument('json_path',
+ help='HistogramSet JSON file path (input).')
+ parser.add_argument('csv_path',
+ help='CSV file path (output).')
+ parser.add_argument('-h', '--help', action='help',
+ help='Show this help message and exit.')
+ args = parser.parse_args()
+ result = histograms_to_csv.HistogramsToCsv(args.json_path)
+ if result.returncode != 0:
+ sys.stderr.write(result.stdout)
+ else:
+ file(args.csv_path, 'w').write(result.stdout)
+ return result.returncode
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/catapult/tracing/bin/histograms2html b/chromium/third_party/catapult/tracing/bin/histograms2html
new file mode 100755
index 00000000000..454c98d154f
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/histograms2html
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import codecs
+import json
+import sys
+import os
+
+tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(tracing_path)
+from tracing_build import render_histograms_viewer
+from tracing_build import vulcanize_histograms_viewer
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Upgrade a results.html or add a new HistogramSet.',
+ add_help=False)
+ parser.add_argument('html_path', metavar='HTML_PATH',
+ help='HTML file path (output).')
+ parser.add_argument('-h', '--help', action='help',
+ help='Show this help message and exit.')
+ parser.add_argument('--html', nargs='+', default=[],
+ help='Zero or more HTML file paths (input).')
+ parser.add_argument('--json', nargs='+', default=[],
+ help='Zero or more HistogramSet JSON file paths (input).')
+ parser.add_argument('--mapresults', nargs='+', default=[],
+ help='Zero or more map results JSON file paths (input).')
+ args = parser.parse_args()
+
+ histograms = []
+
+ for html_path in args.html:
+ histograms.extend(render_histograms_viewer.ReadExistingResults(
+ open(html_path, 'r').read()))
+
+ for json_path in args.json:
+ histograms.extend(json.load(open(json_path, 'r')))
+
+ for json_path in args.mapresults:
+ for filename, results in json.load(open(json_path, 'r')).iteritems():
+ for histogram in results['pairs']['histograms']:
+ histograms.append(histogram)
+
+ open(args.html_path, 'a').close() # Create file if it doesn't exist.
+ with codecs.open(args.html_path,
+ mode='r+', encoding='utf-8') as output_stream:
+ vulcanize_histograms_viewer.VulcanizeAndRenderHistogramsViewer(
+ histograms, output_stream)
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/catapult/tracing/bin/html2trace b/chromium/third_party/catapult/tracing/bin/html2trace
new file mode 100755
index 00000000000..82161fb1cfd
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/html2trace
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import codecs
+import sys
+import os
+
+tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(tracing_path)
+from tracing_build import html2trace
+
+
+def main():
+ parser = argparse.ArgumentParser(description='Extract trace data from an '
+ 'HTML trace.', add_help=False)
+ parser.add_argument('html_path', metavar='HTML_PATH',
+ help='HTML file path (input).')
+ parser.add_argument('trace_path', metavar='TRACE_PATH',
+ help='Trace file path (output). If the HTML file '
+ 'contains more than one trace data block, the first '
+ 'block will be extracted into %(metavar)s and the rest '
+ 'will be extracted into separate files %(metavar)s.1, '
+ '%(metavar)s.2, etc.')
+ parser.add_argument('--gzipped_output', choices=['true', 'false', 'auto'],
+ default='auto', help='Flag whether the output trace '
+ 'file should be gzipped.')
+ parser.add_argument('-q', '--quiet', action='store_true',
+ help='Don\'t print the saved file name(s).')
+ parser.add_argument('-h', '--help', action='help',
+ help='Show this help message and exit.')
+ args = parser.parse_args()
+
+ if args.gzipped_output == 'true':
+ gzipped_output = True
+ elif args.gzipped_output == 'false':
+ gzipped_output = False
+ else:
+ gzipped_output = args.trace_path.endswith('.gz')
+
+ with codecs.open(args.html_path, mode='r', encoding='utf-8') as html_file:
+ saved_paths = html2trace.CopyTraceDataFromHTMLFilePath(
+ html_file, args.trace_path, gzipped_output)
+
+ if not args.quiet:
+ print '\n'.join(saved_paths)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/catapult/tracing/bin/index.html b/chromium/third_party/catapult/tracing/bin/index.html
new file mode 100644
index 00000000000..a4f68f0635e
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/index.html
@@ -0,0 +1,115 @@
+<!DOCTYPE html>
+<!--
+Copyright (c) 2014 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+<head>
+<script>
+'use strict';
+
+function onTraceViewerImportFail() {
+ document.addEventListener('DOMContentLoaded', function() {
+ document.body.textContent =
+ 'tracing/bin/trace_viewer_full.html is missing. ' +
+ 'Run vulcanize_trace_viewer from $TRACE_VIEWER and reload.';
+ });
+}
+</script>
+<link rel="import" href="trace_viewer_full.html"
+ onerror="onTraceViewerImportFail(event)">
+
+<style>
+ html, body {
+ box-sizing: border-box;
+ overflow: hidden;
+ margin: 0px;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+ }
+ #trace-viewer {
+ width: 100%;
+ height: 100%;
+ }
+ #trace-viewer:focus {
+ outline: none;
+ }
+</style>
+<script>
+'use strict';
+
+(function() {
+ var viewer;
+ var url;
+ var model;
+
+ function load() {
+ var req = new XMLHttpRequest();
+ var isBinary = /[.]gz$/.test(url) || /[.]zip$/.test(url);
+ req.overrideMimeType('text/plain; charset=x-user-defined');
+ req.open('GET', url, true);
+ if (isBinary)
+ req.responseType = 'arraybuffer';
+
+ req.onreadystatechange = function(event) {
+ if (req.readyState !== 4)
+ return;
+
+ window.setTimeout(function() {
+ if (req.status === 200)
+ onResult(isBinary ? req.response : req.responseText);
+ else
+ onResultFail(req.status);
+ }, 0);
+ };
+ req.send(null);
+ }
+
+ function onResultFail(err) {
+ var overlay = new tr.ui.b.Overlay();
+ overlay.textContent = err + ': ' + url + ' could not be loaded';
+ overlay.title = 'Failed to fetch data';
+ overlay.visible = true;
+ }
+
+ function onResult(result) {
+ model = new tr.Model();
+ var i = new tr.importer.Import(model);
+ var p = i.importTracesWithProgressDialog([result]);
+ p.then(onModelLoaded, onImportFail);
+ }
+
+ function onModelLoaded() {
+ viewer.model = model;
+ viewer.viewTitle = url;
+ }
+
+ function onImportFail() {
+ var overlay = new tr.ui.b.Overlay();
+ overlay.textContent = tr.b.normalizeException(err).message;
+ overlay.title = 'Import error';
+ overlay.visible = true;
+ }
+
+ document.addEventListener('DOMContentLoaded', function() {
+ var container = document.createElement('track-view-container');
+ container.id = 'track_view_container';
+
+ viewer = document.createElement('tr-ui-timeline-view');
+ viewer.track_view_container = container;
+ Polymer.dom(viewer).appendChild(container);
+
+ viewer.id = 'trace-viewer';
+ viewer.globalMode = true;
+ Polymer.dom(document.body).appendChild(viewer);
+
+ url = '../test_data/big_trace.json';
+ load();
+ });
+}());
+</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/chromium/third_party/catapult/tracing/bin/label_histograms b/chromium/third_party/catapult/tracing/bin/label_histograms
new file mode 100755
index 00000000000..07488964b99
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/label_histograms
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright 2019 The Chromium 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 argparse
+import codecs
+import json
+import sys
+import os
+
+tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(tracing_path)
+from tracing.value import histogram_set
+from tracing.value.diagnostics import generic_set
+from tracing.value.diagnostics import reserved_infos
+from tracing_build import render_histograms_viewer
+from tracing_build import vulcanize_histograms_viewer
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Add a label to Histograms in an HTML or JSON file.',
+ add_help=False)
+ parser.add_argument('path', metavar='PATH',
+ help='HTML file path (output).')
+ parser.add_argument('label', metavar='LABEL',
+ help='The label to add to Histograms.')
+ args = parser.parse_args()
+
+ histograms = []
+
+ if args.path.endswith('.html'):
+ histograms.extend(render_histograms_viewer.ReadExistingResults(
+ open(args.path, 'r').read()))
+ elif args.path.endswith('.json'):
+ histograms.extend(json.load(open(json_path, 'r')))
+ else:
+ raise Error('Use either .html or .json extension.')
+ histograms = histogram_set.HistogramSet(histograms)
+ histograms.AddSharedDiagnosticToAllHistograms(
+ reserved_infos.LABELS.name,
+ generic_set.GenericSet([args.label]))
+
+ with codecs.open(args.path,
+ mode='r+', encoding='utf-8') as output_stream:
+ if args.path.endswith('.html'):
+ vulcanize_histograms_viewer.VulcanizeAndRenderHistogramsViewer(
+ histograms, output_stream)
+ else:
+ json.dump(histograms.AsDicts(), output_stream)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/catapult/tracing/bin/map_traces b/chromium/third_party/catapult/tracing/bin/map_traces
new file mode 100755
index 00000000000..af58491504d
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/map_traces
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
+ '..'))
+ sys.path.append(tracing_path)
+ from tracing.mre import map_traces
+ sys.exit(map_traces.Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/memory_infra_remote_dump b/chromium/third_party/catapult/tracing/bin/memory_infra_remote_dump
new file mode 100755
index 00000000000..3125e9fe10d
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/memory_infra_remote_dump
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""Grabs before/after memory dumps using the devtools remote protocol.
+
+To use it you first start Chrome with remote debugging enabled then run the
+script which will take a memory dump, wait for you to press enter, take
+another memory dump and finally save a trace file. For example:
+
+On OSX:
+$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
+ --remote-debugging-port=9222 \\
+ --memlog=all --memlog-sampling --memlog-stack-mode=pseudo \\
+$ ./tracing/bin/memory_infra_remote_dump --port=9222
+...
+[Press enter to stop tracing]
+...
+/var/folders/18/gl6q632j20nc_tw5g9l03dhc007g45/T/trace_20s191.json: 835 KB
+
+On Android:
+$ ./build/android/adb_chrome_public_command_line \\
+ --memlog=all --memlog-sampling --memlog-stack-mode=pseudo \\
+ --enable-remote-debugging
+$ ./build/android/adb_run_chrome_public
+$ adb forward tcp:1234 localabstract:chrome_devtools_remote
+$ ./third_party/catapult/tracing/bin/memory_infra_remote_dump --port=1234
+...
+[Press enter to stop tracing]
+...
+/var/folders/18/gl6q632j20nc_tw5g9l03dhc007g45/T/trace_20s191.json: 835 KB
+"""
+
+import argparse
+import json
+import os
+import requests
+import sys
+import tempfile
+import time
+
+try:
+ import websocket
+except ImportError:
+ print 'Please run: pip install --user websocket-client'
+ sys.exit(1)
+
+
+class TracingDevtoolsClient(object):
+ def __init__(self, host, port):
+ r = requests.get('http://%s:%s/json/version' % (host, port))
+ url = r.json()['webSocketDebuggerUrl']
+ print 'Connecting to ' + url
+ self.ws = websocket.create_connection(url)
+ self.cmd = 0
+
+ def send(self, method, params={}):
+ self.cmd += 1
+ self.ws.send(
+ json.dumps({'id': self.cmd, 'method': method, 'params': params}))
+ resp = self.recv()
+ assert resp['id'] == self.cmd
+ return resp.get('result', {})
+
+ def recv(self):
+ return json.loads(self.ws.recv())
+
+ def req_memory_dump(self):
+ print 'Requesting memory dump...',
+ resp = self.send('Tracing.requestMemoryDump')
+ assert resp['success'] == True
+ print ' ...done'
+
+ def dump(self, trace_fd):
+ trace_config = {
+ 'excludedCategories': ['*'],
+ 'includedCategories': ['disabled-by-default-memory-infra'],
+ 'memoryDumpConfig': {'triggers': []}
+ }
+ print 'Starting trace with trace_config', trace_config
+ params = {'traceConfig': trace_config, 'transferMode': 'ReturnAsStream'}
+ self.send('Tracing.start', params)
+ self.req_memory_dump()
+
+ if sys.stdin.isatty():
+ while True:
+ try:
+ print '[Press enter to trigger a new dump, q to finish the trace]'
+ cmd = raw_input()
+ except KeyboardInterrupt:
+ break
+ if cmd == 'q':
+ break
+ self.req_memory_dump()
+
+ self.send('Tracing.end')
+
+ # Wait for trace completion
+ print 'Flushing trace'
+ resp = self.recv()
+ assert resp['method'] == 'Tracing.tracingComplete'
+ stream_handle = resp['params']['stream']
+
+ # Read back the trace stream
+ resp = {'eof': False}
+ while not resp['eof']:
+ resp = self.send('IO.read', {'handle': stream_handle})
+ trace_fd.write(resp['data'].encode('utf-8'))
+
+ self.send('IO.close', {'handle': stream_handle})
+ trace_fd.close()
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(
+ description=__doc__,
+ formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument('--host', default='localhost')
+ parser.add_argument('--port', '-p', default=9222)
+ parser.add_argument('--output-trace', '-o', default=None)
+ args = parser.parse_args()
+
+ if args.output_trace is None:
+ trace_fd = tempfile.NamedTemporaryFile(prefix='trace_', suffix='.json',
+ delete=False)
+ else:
+ trace_fd = open(args.output_trace, 'wb')
+
+ cli = TracingDevtoolsClient(args.host, args.port)
+ cli.dump(trace_fd)
+ print '\n%s: %d KB' % (trace_fd.name, os.stat(trace_fd.name).st_size / 1000)
diff --git a/chromium/third_party/catapult/tracing/bin/merge_histograms b/chromium/third_party/catapult/tracing/bin/merge_histograms
new file mode 100755
index 00000000000..1d3f1ccca12
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/merge_histograms
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import json
+import os
+import sys
+
+tracing_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+sys.path.append(tracing_path)
+from tracing.value import merge_histograms
+
+def Main(argv):
+ parser = argparse.ArgumentParser(
+ description='Merge Histograms.')
+ parser.add_argument('input', type=str,
+ help='Path to a HistogramSet JSON file. (input)')
+ parser.add_argument('output', type=str,
+ help='Path to a HistogramSet JSON file. (output)')
+ parser.add_argument('groupby', nargs='+',
+ help='One or more grouping keys (name, benchmark, ' +
+ 'time, storyset_repeat, story_repeat, story, tir, label)')
+ args = parser.parse_args(argv[1:])
+
+ merged = merge_histograms.MergeHistograms(args.input, args.groupby)
+ json.dump(merged, file(args.output, 'w'))
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/merge_traces b/chromium/third_party/catapult/tracing/bin/merge_traces
new file mode 100755
index 00000000000..4b610dd0699
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/merge_traces
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+ sys.path.append(tracing_path)
+ from tracing_build import merge_traces
+ sys.exit(merge_traces.Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/results2json b/chromium/third_party/catapult/tracing/bin/results2json
new file mode 100755
index 00000000000..fe90f196614
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/results2json
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import json
+import sys
+import os
+
+tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(tracing_path)
+from tracing_build import render_histograms_viewer
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Extract HistogramSet JSON from results.html.',
+ add_help=False)
+ parser.add_argument('html_path', metavar='HTML_PATH',
+ help='HTML file path (input).')
+ parser.add_argument('json_path', metavar='JSON_PATH',
+ help='JSON file path (input/output).')
+ parser.add_argument('-h', '--help', action='help',
+ help='Show this help message and exit.')
+ args = parser.parse_args()
+
+ histograms = render_histograms_viewer.ReadExistingResults(
+ open(args.html_path, 'r').read())
+ if os.path.exists(args.json_path):
+ histograms.extend(json.load(open(args.json_path, 'r')))
+ json.dump(histograms, open(args.json_path, 'w'))
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/catapult/tracing/bin/run_dev_server_tests b/chromium/third_party/catapult/tracing/bin/run_dev_server_tests
new file mode 100755
index 00000000000..bd09476721e
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/run_dev_server_tests
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..', '..'))
+ sys.path.append(tracing_path)
+ from catapult_build import run_dev_server_tests
+ sys.exit(run_dev_server_tests.Main(sys.argv + ['--tests=tracing']))
diff --git a/chromium/third_party/catapult/tracing/bin/run_metric b/chromium/third_party/catapult/tracing/bin/run_metric
new file mode 100755
index 00000000000..d10719141c0
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/run_metric
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import codecs
+import json
+import os
+import sys
+
+sys.path.insert(1, os.path.join(os.path.dirname(__file__), '..'))
+from tracing_build import vulcanize_histograms_viewer
+from tracing.metrics import metric_runner
+from tracing.metrics import discover
+
+def Main(argv):
+ all_metrics = discover.DiscoverMetrics(
+ ['/tracing/metrics/all_metrics.html'])
+
+ parser = argparse.ArgumentParser(
+ description='Runs metrics on local traces')
+ parser.add_argument('trace_file_or_dir',
+ help='A trace file, or a dir containing trace files')
+ parser.add_argument('metrics', nargs='+',
+ help=('Function names of registered metrics '
+ '(not filenames.) '
+ 'Available metrics are: %s' %
+ ', '.join(all_metrics)),
+ choices=all_metrics, metavar='metricName')
+ parser.add_argument('--filename', default='results', type=str,
+ help='Output file name (no extension)')
+ parser.add_argument('--reset', action='store_true',
+ help=('Whether to ignore existing results in HTML file '
+ '(if it exists'))
+ parser.add_argument('--also-output-json', action='store_true',
+ help=('Also output json file containing values. Note that'
+ 'this only contains the results of current run'))
+
+ args = parser.parse_args(argv[1:])
+ trace_file_or_dir = os.path.abspath(args.trace_file_or_dir)
+
+ if os.path.isdir(trace_file_or_dir):
+ trace_dir = trace_file_or_dir
+ traces = [os.path.join(trace_dir, trace) for trace in os.listdir(trace_dir)]
+ else:
+ traces = [trace_file_or_dir]
+
+ failures = []
+ histograms = []
+ for trace_url, mre_result in metric_runner.RunMetricOnTraces(
+ traces, args.metrics).iteritems():
+ failures.extend(mre_result.failures)
+ histograms.extend(mre_result.pairs.get('histograms', []))
+
+ if failures:
+ print 'Running metric failed:'
+ for failure in failures:
+ print failure.stack
+
+ output_file = args.filename + '.html'
+ open(output_file, 'a').close() # Create file if it doesn't exist.
+ with codecs.open(output_file, mode='r+', encoding='utf-8') as output_stream:
+ vulcanize_histograms_viewer.VulcanizeAndRenderHistogramsViewer(
+ histograms, output_stream, args.reset)
+ print 'HTML result created in file://' + os.path.abspath(output_file)
+
+ if args.also_output_json:
+ output_file = args.filename + '.json'
+ with open(output_file, 'w') as f:
+ json.dump(histograms, f, indent=2, sort_keys=True, separators=(',', ': '))
+ print 'JSON result created in file://' + os.path.abspath(output_file)
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/run_node_tests b/chromium/third_party/catapult/tracing/bin/run_node_tests
new file mode 100755
index 00000000000..d044e0f1c22
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/run_node_tests
@@ -0,0 +1,23 @@
+#!/usr/bin/env node
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+'use strict';
+
+var fs = require('fs');
+var path = require('path');
+
+var catapultPath = fs.realpathSync(path.join(__dirname, '..', '..'));
+var catapultBuildPath = path.join(catapultPath, 'catapult_build');
+
+var node_bootstrap = require(path.join(catapultBuildPath, 'node_bootstrap.js'));
+
+HTMLImportsLoader.addArrayToSourcePath(
+ node_bootstrap.getSourcePathsForProject('tracing'));
+
+// Go!
+var headless_test_module_filenames =
+ node_bootstrap.getHeadlessTestModuleFilenamesForProject('tracing');
+
+HTMLImportsLoader.loadHTML('/tracing/base/headless_tests.html');
+tr.b.unittest.loadAndRunTests(headless_test_module_filenames); \ No newline at end of file
diff --git a/chromium/third_party/catapult/tracing/bin/run_py_tests b/chromium/third_party/catapult/tracing/bin/run_py_tests
new file mode 100755
index 00000000000..e81cb180b79
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/run_py_tests
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium 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 platform
+import sys
+
+_CATAPULT_PATH = os.path.abspath(
+ os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ os.path.pardir,
+ os.path.pardir))
+_TRACING_PATH = os.path.join(_CATAPULT_PATH, 'tracing')
+
+sys.path.insert(0, _TRACING_PATH)
+from tracing import tracing_project
+
+
+def _RunTestsOrDie(top_level_dir):
+ path = [_TRACING_PATH]
+ path.extend(tracing_project.GetDependencyPaths())
+ exit_code = run_with_typ.Run(top_level_dir, path=path)
+ if exit_code:
+ sys.exit(exit_code)
+
+
+def _AddToPathIfNeeded(path):
+ if path not in sys.path:
+ sys.path.insert(0, path)
+
+
+if __name__ == '__main__':
+ _AddToPathIfNeeded(_CATAPULT_PATH)
+
+ from hooks import install
+ if '--no-install-hooks' in sys.argv:
+ sys.argv.remove('--no-install-hooks')
+ else:
+ install.InstallHooks()
+
+ from catapult_build import run_with_typ
+ _RunTestsOrDie(os.path.join(_TRACING_PATH, 'tracing'))
+ _RunTestsOrDie(os.path.join(_TRACING_PATH, 'tracing_build'))
+ sys.exit(0)
diff --git a/chromium/third_party/catapult/tracing/bin/run_symbolizer_tests b/chromium/third_party/catapult/tracing/bin/run_symbolizer_tests
new file mode 100755
index 00000000000..3f311753676
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/run_symbolizer_tests
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+The symbolizer tests take a long time to run [potentially 5+ minutes each], so
+they are invoked directly from separately from run_py_tests.
+"""
+
+import os
+import sys
+
+_CATAPULT_PATH = os.path.abspath(
+ os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ os.path.pardir,
+ os.path.pardir))
+_TRACING_PATH = os.path.join(_CATAPULT_PATH, 'tracing')
+
+
+def _RunTestsOrDie(top_level_dir):
+ exit_code = run_with_typ.Run(top_level_dir, path=[_TRACING_PATH],
+ suffixes=['*_test_slow.py'])
+ if exit_code:
+ sys.exit(exit_code)
+
+
+def _AddToPathIfNeeded(path):
+ if path not in sys.path:
+ sys.path.insert(0, path)
+
+
+if __name__ == '__main__':
+ _AddToPathIfNeeded(_CATAPULT_PATH)
+
+ from catapult_build import run_with_typ
+ _RunTestsOrDie(os.path.join(_TRACING_PATH, 'tracing', 'extras', 'symbolizer'))
+ sys.exit(0)
diff --git a/chromium/third_party/catapult/tracing/bin/run_tests b/chromium/third_party/catapult/tracing/bin/run_tests
new file mode 100755
index 00000000000..3f94c67af0b
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/run_tests
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium 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
+
+
+_THIS_PATH = os.path.dirname(os.path.realpath(__file__))
+_TESTS = [
+ {'path': os.path.join(_THIS_PATH, 'run_py_tests')},
+ {'path': os.path.join(_THIS_PATH, 'run_vinn_tests'),
+ 'disabled': {'win32'}},
+ {'path': os.path.join(_THIS_PATH, 'run_dev_server_tests'),
+ 'chrome_path_arg': True}
+]
+
+
+if __name__ == '__main__':
+ catapult_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..', '..'))
+ sys.path.append(catapult_path)
+ from catapult_build import test_runner
+ sys.exit(test_runner.Main('tracing', _TESTS, sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/run_vinn_tests b/chromium/third_party/catapult/tracing/bin/run_vinn_tests
new file mode 100755
index 00000000000..42ec180f119
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/run_vinn_tests
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+ sys.path.append(tracing_path)
+ from tracing_build import run_vinn_tests
+ sys.exit(run_vinn_tests.Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/slim_trace b/chromium/third_party/catapult/tracing/bin/slim_trace
new file mode 100755
index 00000000000..2e170777840
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/slim_trace
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 sys
+import os
+
+tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+sys.path.append(tracing_path)
+from tracing_build import slim_trace
+
+
+if __name__ == '__main__':
+ sys.exit(slim_trace.Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/strip_memory_infra_trace b/chromium/third_party/catapult/tracing/bin/strip_memory_infra_trace
new file mode 100755
index 00000000000..8bdc8375d75
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/strip_memory_infra_trace
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
+ sys.path.append(tracing_path)
+ from tracing_build import strip_memory_infra_trace
+ sys.exit(strip_memory_infra_trace.Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/symbolize_trace b/chromium/third_party/catapult/tracing/bin/symbolize_trace
new file mode 100755
index 00000000000..c2bee858e43
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/symbolize_trace
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium 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
+
+tracing_path = os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '..'))
+sys.path.append(tracing_path)
+import tracing_project
+tracing_project.UpdateSysPathIfNeeded()
+
+if __name__ == '__main__':
+ from tracing.extras.symbolizer import symbolize_trace
+ sys.exit(symbolize_trace.main(sys.argv[1:]))
diff --git a/chromium/third_party/catapult/tracing/bin/trace2html b/chromium/third_party/catapult/tracing/bin/trace2html
new file mode 100755
index 00000000000..0457d39a66b
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/trace2html
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright (c) 2014 The Chromium 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 sys
+import os
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+ sys.path.append(tracing_path)
+ from tracing_build import trace2html
+ sys.exit(trace2html.Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/update_gni b/chromium/third_party/catapult/tracing/bin/update_gni
new file mode 100755
index 00000000000..b2bc2291846
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/update_gni
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+ sys.path.append(tracing_path)
+ from tracing_build import update_gni
+ sys.exit(update_gni.Update())
diff --git a/chromium/third_party/catapult/tracing/bin/validate_all_diagnostics b/chromium/third_party/catapult/tracing/bin/validate_all_diagnostics
new file mode 100755
index 00000000000..f8bd5badaf0
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/validate_all_diagnostics
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium 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 argparse
+import json
+import os
+import string
+import sys
+
+sys.path.insert(
+ 1,
+ os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
+import tracing_project
+tracing_project.UpdateSysPathIfNeeded()
+
+from py_utils import camel_case
+from py_utils import discover
+
+from tracing.value.diagnostics import diagnostic
+from tracing.value.diagnostics import all_diagnostics
+
+import vinn
+
+
+_DISCOVER_CMDLINE = os.path.join(
+ os.path.dirname(__file__), '..', 'tracing', 'value', 'diagnostics',
+ 'discover_cmdline.html')
+
+
+def DiscoverJSDiagnostics(project, js_args):
+ res = vinn.RunFile(_DISCOVER_CMDLINE, source_paths=list(project.source_paths),
+ js_args=js_args)
+ if res.returncode != 0:
+ raise RuntimeError('Error running diagnostics/discover_cmdline: ' + res.stdout)
+ else:
+ return set([str(m) for m in json.loads(res.stdout)])
+
+
+def DiscoverPythonDiagnostics():
+ return discover.DiscoverClasses(
+ os.path.join(tracing_project.TracingProject.tracing_src_path,
+ 'value'),
+ tracing_project.TracingProject.tracing_root_path,
+ diagnostic.Diagnostic, index_by_class_name=True)
+
+
+def CheckPythonDiagnostics():
+ discovered_diagnostics = DiscoverPythonDiagnostics()
+
+ registered_diagnostic_names = [
+ camel_case.ToUnderscore(name)
+ for name in all_diagnostics.GetDiagnosticTypenames()]
+
+ unregistered_diagnostics = (set(discovered_diagnostics.keys()) -
+ set(registered_diagnostic_names))
+
+ return_code = 0
+ if unregistered_diagnostics:
+ print ('These diagnostics are unregistered: %s. Please add them to '
+ 'tracing/tracing/value/diagnostics/all_diagnostics.py.' %
+ ', '.join(unregistered_diagnostics))
+ return_code = 1
+
+ for name in all_diagnostics.GetDiagnosticTypenames():
+ diagnostic = all_diagnostics.GetDiagnosticClassForName(name)
+ if name != diagnostic.__name__:
+ print 'This diagnostic refers to the wrong class: %s: %s' % (
+ name, diagnostic.__name__)
+ return_code = 1
+
+ return return_code
+
+
+def CheckJSDiagnostics():
+ project = tracing_project.TracingProject()
+ all_registered_diagnostics = DiscoverJSDiagnostics(
+ project, ['registry', '/tracing/value/diagnostics/all_diagnostics.html'])
+ all_modules = list(
+ '/' + rel_path for rel_path in
+ tracing_project.TracingProject().FindAllDiagnosticsModuleRelPaths())
+ all_possible_diagnostics = DiscoverJSDiagnostics(
+ project, ['namespace'] + all_modules)
+
+ unregistered_diagnostics = (all_possible_diagnostics -
+ all_registered_diagnostics)
+ if unregistered_diagnostics:
+ print ('These diagnostics are unregistered: %s. Please import their modules in '
+ 'tracing/tracing/value/diagnostics/all_diagnostics.html and '
+ 'ensure that they call Diagnostic.register().' %
+ ', '.join(unregistered_diagnostics))
+ return 1
+
+ lowercased_diagnostics = []
+ for m in all_possible_diagnostics:
+ if str.islower(m[0]):
+ lowercased_diagnostics.append(m)
+ if lowercased_diagnostics:
+ print ('These diagnostics must be renamed to start with a upper-case: %s' %
+ lowercased_diagnostics)
+ return 1
+
+ return 0
+
+
+def Main():
+ return (CheckJSDiagnostics() or CheckPythonDiagnostics())
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/chromium/third_party/catapult/tracing/bin/validate_all_metrics b/chromium/third_party/catapult/tracing/bin/validate_all_metrics
new file mode 100755
index 00000000000..b4b26307bc1
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/validate_all_metrics
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium 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 argparse
+import json
+import os
+import string
+import sys
+
+sys.path.insert(
+ 1,
+ os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
+from tracing.metrics import discover
+import tracing_project
+
+
+def Main():
+ all_registered_metrics = set(discover.DiscoverMetrics(
+ ['/tracing/metrics/all_metrics.html']))
+ all_modules = list(
+ '/' + rel_path for rel_path in
+ tracing_project.TracingProject().FindAllMetricsModuleRelPaths())
+ all_possible_metrics = set(discover.DiscoverMetrics(all_modules))
+ unregistered_metrics = all_possible_metrics - all_registered_metrics
+ if unregistered_metrics:
+ print ('These metrics are unregistered: %s. Please import their modules in '
+ 'tracing/tracing/metrics/all_metrics.html' %
+ ', '.join(unregistered_metrics))
+ return 1
+ uppercased_metrics = []
+ for m in all_possible_metrics:
+ if str.isupper(m[0]):
+ uppercased_metrics.append(m)
+ if uppercased_metrics:
+ print ('These metrics must be renamed to start with a lower-case: %s' %
+ uppercased_metrics)
+ return 1
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/chromium/third_party/catapult/tracing/bin/vulcanize_trace_viewer b/chromium/third_party/catapult/tracing/bin/vulcanize_trace_viewer
new file mode 100755
index 00000000000..c3602d40447
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/vulcanize_trace_viewer
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+# Copyright (c) 2014 The Chromium 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
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+ sys.path.append(tracing_path)
+ from tracing_build import vulcanize_trace_viewer
+ sys.exit(vulcanize_trace_viewer.Main(sys.argv))
diff --git a/chromium/third_party/catapult/tracing/bin/why_imported b/chromium/third_party/catapult/tracing/bin/why_imported
new file mode 100755
index 00000000000..9b5a59a6f49
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/bin/why_imported
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Produces a dot file showing dependency relationships between modules.
+
+The dot file contains a text-based representation of a directed graph that
+explains why given module names were included in a trace_viewer config.
+
+Example usage:
+$ ./why_imported tracing.ui.analysis.analysis_view > ~/analysis_view.dot
+
+This can then be converted to a graphical representation with the dot tool:
+$ dot -Grankdir=LR -Tpng ~/analysis_view.dot -o ~/analysis_view.png
+"""
+
+import os
+import sys
+import argparse
+
+
+def Main():
+ project = tracing_project.TracingProject()
+
+ parser = argparse.ArgumentParser(
+ usage='%(prog)s <options> moduleNames', epilog=__doc__)
+ parser.add_argument('--config', choices=project.GetConfigNames())
+ parser.add_argument('module_names', nargs='+')
+ args = parser.parse_args()
+
+ if args.config:
+ names = [project.GetModuleNameForConfigName(options.config)]
+ vulcanizer = project.CreateVulcanizer()
+ load_sequence = vulcanizer.CalcLoadSequenceForModuleNames(names)
+ else:
+ parser.error('No config specified.')
+ print vulcanizer.GetDominatorGraphForModulesNamed(
+ args.module_names, load_sequence)
+
+
+if __name__ == '__main__':
+ tracing_path = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), '..'))
+ sys.path.append(tracing_path)
+ import tracing_project
+ tracing_project.UpdateSysPathIfNeeded()
+ sys.exit(Main())