summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/mre/reduce_map_results_cmdline.html
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/mre/reduce_map_results_cmdline.html')
-rw-r--r--chromium/third_party/catapult/tracing/tracing/mre/reduce_map_results_cmdline.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/mre/reduce_map_results_cmdline.html b/chromium/third_party/catapult/tracing/tracing/mre/reduce_map_results_cmdline.html
new file mode 100644
index 00000000000..1a99fcad758
--- /dev/null
+++ b/chromium/third_party/catapult/tracing/tracing/mre/reduce_map_results_cmdline.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<!--
+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.
+-->
+
+<link rel="import" href="/tracing/base/xhr.html">
+<link rel="import" href="/tracing/mre/file_handle.html">
+<link rel="import" href="/tracing/mre/job.html">
+<link rel="import" href="/tracing/mre/mre_result.html">
+<link rel="import" href="/tracing/mre/reduce_map_results.html">
+<link rel="import" href="/tracing/mre/run_and_convert_errors_to_failures.html">
+<link rel="import" href="/tracing/value/histogram.html">
+
+<script>
+'use strict';
+
+tr.exportTo('tr.mre', function() {
+
+ function jsonReplacer(key, value) {
+ if (value instanceof tr.v.Histogram) {
+ return value.asDict();
+ }
+ return value;
+ }
+
+ function reduceMapResultsMain(args) {
+ if (args.length !== 3)
+ throw new Error('Must provide three arguments');
+
+ var options = {
+ key: args[0],
+ fileHandle: tr.mre.FileHandle.fromDict(JSON.parse(args[1])),
+ job: tr.mre.Job.fromDict(JSON.parse(args[2]))
+ };
+
+ var mapResultsLoaded = options.fileHandle.load();
+ var mapResults = JSON.parse(mapResultsLoaded);
+
+ var jobResults = new tr.mre.MreResult();
+
+ tr.mre.runAndConvertErrorsToFailures(
+ jobResults, options.job, options.job.reduceFunctionHandle,
+ undefined,
+ function() {
+ var reduceFunction = options.job.reduceFunctionHandle.load();
+ tr.mre.reduceMapResults(jobResults, options.key, mapResults.pairs,
+ reduceFunction);
+ });
+
+ if (Object.keys(jobResults.pairs).length !== 0)
+ console.log('JOB_RESULTS: ' + JSON.stringify(jobResults.pairs,
+ jsonReplacer));
+ jobResults.failures.forEach(function(failure) {
+ console.log('JOB_FAILURE: ' + JSON.stringify(failure.asDict()));
+ });
+ return 0;
+ }
+
+ return {
+ reduceMapResultsMain: reduceMapResultsMain
+ };
+});
+
+
+if (tr.isHeadless)
+ quit(tr.mre.reduceMapResultsMain(sys.argv.slice(1)));
+
+</script>