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

Side by Side Diff: trace_processor/experimental/mappers/v8_callstats_dump.html

Issue 2461733002: [v8 runtime stats] Migrate the runtime stats mapper to use the runtime stats metric instead (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2015 The Chromium Authors. All rights reserved. 3 Copyright 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 <link rel="import" href="/tracing/base/iteration_helpers.html"> 7 <link rel="import" href="/tracing/base/iteration_helpers.html">
8 <link rel="import" href="/tracing/metrics/system_health/loading_metric.html"> 8 <link rel="import" href="/tracing/metrics/v8/runtime_stats_metric.html">
9 <link rel="import" href="/tracing/mre/function_handle.html"> 9 <link rel="import" href="/tracing/mre/function_handle.html">
10 <link rel="import" href="/tracing/value/value_set.html"> 10 <link rel="import" href="/tracing/value/histogram_set.html">
11 11
12 <script> 12 <script>
13 'use strict'; 13 'use strict';
14 14
15 15
16 tr.exportTo('tr.mre', function() { 16 tr.exportTo('tr.mre', function() {
17 function v8CallStatsDump(result, model) { 17 function v8CallStatsDump(result, model) {
18 var v8_runtime_map = {}; 18 var values = new tr.v.HistogramSet();
19 var totalCount = 0;
20 var totalTime = 0;
21 var values = new tr.v.ValueSet();
22 19
23 tr.metrics.sh.loadingMetric(values, model); 20 tr.metrics.v8.runtimeStatsMetric(values, model);
24 var ttiEntries = values.valueDicts.filter( 21 var runtimeStatsMap = new Map();
25 (dict) => dict.name === 'timeToFirstInteractive'); 22 for (var value of values.sourceValues) {
26 var numeric = ttiEntries[0].numeric; 23 var arr = value.name.split(':');
27 if (numeric.running.count > 1) { 24 if (runtimeStatsMap[arr[0]] === undefined) {
28 throw 'Unable to work with a trace that has more than one navigation'; 25 runtimeStatsMap[arr[0]] = {time: null, count: null};
29 } 26 }
30 27 if (arr[1] === 'count') {
31 var binsWithSampleDiagnosticMaps = numeric.centralBins.filter( 28 runtimeStatsMap[arr[0]].count = value.sum;
32 (bin) => bin.diagnosticMaps.length > 0); 29 } else {
33 var diagnostic = binsWithSampleDiagnosticMaps[0] 30 runtimeStatsMap[arr[0]].time = Number(value.sum).toFixed(2);
34 .diagnosticMaps[0]['breakdown'];
35
36 var tti = diagnostic.value.interactive;
37
38 for (var event of model.getDescendantEvents()) {
39 if (!(event instanceof tr.model.ThreadSlice) || event.start > tti)
40 continue;
41 var v8_runtime = event.args['runtime-call-stats'];
42
43 // For older traces, check if we had an arg called 'runtime-call-stat'
44 // instead.
45 if (v8_runtime === undefined)
46 v8_runtime = event.args['runtime-call-stat'];
47
48 if (v8_runtime !== undefined) {
49 try {
50 var v8_runtime_object = JSON.parse(v8_runtime);
51 for (var runtime_call in v8_runtime_object) {
52 // exclude "END" and malformed entries.
53 if (v8_runtime_object[runtime_call].length == 2) {
54 if (v8_runtime_map[runtime_call] === undefined) {
55 v8_runtime_map[runtime_call] = {count: 0, time: 0};
56 }
57 var runtime_count = v8_runtime_object[runtime_call][0];
58 v8_runtime_map[runtime_call].count += runtime_count;
59 var runtime_time = v8_runtime_object[runtime_call][1] / 1000;
60 v8_runtime_map[runtime_call].time += runtime_time;
61 totalCount += runtime_count;
62 totalTime += runtime_time;
63 }
64 }
65 } catch (e) {
66 console.warn(e);
67 }
68 } 31 }
69 } 32 }
70 for (var i in v8_runtime_map) { 33 for (var entry in runtimeStatsMap) {
71 result.addPair(i, {time: Number(v8_runtime_map[i].time).toFixed(2), 34 result.addPair(entry, runtimeStatsMap[entry]);
72 count: v8_runtime_map[i].count});
73 } 35 }
74 result.addPair('Total', {time: Number(totalTime).toFixed(2),
75 count: totalCount});
76 } 36 }
77 37
78 tr.mre.FunctionRegistry.register(v8CallStatsDump); 38 tr.mre.FunctionRegistry.register(v8CallStatsDump);
79 39
80 // Exporting for tests. 40 // Exporting for tests.
81 return { 41 return {
82 v8CallStatsDump: v8CallStatsDump 42 v8CallStatsDump: v8CallStatsDump
83 }; 43 };
84 }); 44 });
85 45
86 </script> 46 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698