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

Unified 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, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trace_processor/experimental/mappers/v8_callstats_dump.html
diff --git a/trace_processor/experimental/mappers/v8_callstats_dump.html b/trace_processor/experimental/mappers/v8_callstats_dump.html
index 4756869e59184c004238f712845e17a7e5aed5f3..bd46dc977f5061bd936768b3e755591fb696c0ba 100644
--- a/trace_processor/experimental/mappers/v8_callstats_dump.html
+++ b/trace_processor/experimental/mappers/v8_callstats_dump.html
@@ -5,9 +5,9 @@ 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/iteration_helpers.html">
-<link rel="import" href="/tracing/metrics/system_health/loading_metric.html">
+<link rel="import" href="/tracing/metrics/v8/runtime_stats_metric.html">
<link rel="import" href="/tracing/mre/function_handle.html">
-<link rel="import" href="/tracing/value/value_set.html">
+<link rel="import" href="/tracing/value/histogram_set.html">
<script>
'use strict';
@@ -15,64 +15,24 @@ found in the LICENSE file.
tr.exportTo('tr.mre', function() {
function v8CallStatsDump(result, model) {
- var v8_runtime_map = {};
- var totalCount = 0;
- var totalTime = 0;
- var values = new tr.v.ValueSet();
-
- tr.metrics.sh.loadingMetric(values, model);
- var ttiEntries = values.valueDicts.filter(
- (dict) => dict.name === 'timeToFirstInteractive');
- var numeric = ttiEntries[0].numeric;
- if (numeric.running.count > 1) {
- throw 'Unable to work with a trace that has more than one navigation';
- }
-
- var binsWithSampleDiagnosticMaps = numeric.centralBins.filter(
- (bin) => bin.diagnosticMaps.length > 0);
- var diagnostic = binsWithSampleDiagnosticMaps[0]
- .diagnosticMaps[0]['breakdown'];
-
- var tti = diagnostic.value.interactive;
-
- for (var event of model.getDescendantEvents()) {
- if (!(event instanceof tr.model.ThreadSlice) || event.start > tti)
- continue;
- var v8_runtime = event.args['runtime-call-stats'];
-
- // For older traces, check if we had an arg called 'runtime-call-stat'
- // instead.
- if (v8_runtime === undefined)
- v8_runtime = event.args['runtime-call-stat'];
-
- if (v8_runtime !== undefined) {
- try {
- var v8_runtime_object = JSON.parse(v8_runtime);
- for (var runtime_call in v8_runtime_object) {
- // exclude "END" and malformed entries.
- if (v8_runtime_object[runtime_call].length == 2) {
- if (v8_runtime_map[runtime_call] === undefined) {
- v8_runtime_map[runtime_call] = {count: 0, time: 0};
- }
- var runtime_count = v8_runtime_object[runtime_call][0];
- v8_runtime_map[runtime_call].count += runtime_count;
- var runtime_time = v8_runtime_object[runtime_call][1] / 1000;
- v8_runtime_map[runtime_call].time += runtime_time;
- totalCount += runtime_count;
- totalTime += runtime_time;
- }
- }
- } catch (e) {
- console.warn(e);
- }
+ var values = new tr.v.HistogramSet();
+
+ tr.metrics.v8.runtimeStatsMetric(values, model);
+ var runtimeStatsMap = new Map();
+ for (var value of values.sourceValues) {
+ var arr = value.name.split(':');
+ if (runtimeStatsMap[arr[0]] === undefined) {
+ runtimeStatsMap[arr[0]] = {time: null, count: null};
+ }
+ if (arr[1] === 'count') {
+ runtimeStatsMap[arr[0]].count = value.sum;
+ } else {
+ runtimeStatsMap[arr[0]].time = Number(value.sum).toFixed(2);
}
}
- for (var i in v8_runtime_map) {
- result.addPair(i, {time: Number(v8_runtime_map[i].time).toFixed(2),
- count: v8_runtime_map[i].count});
+ for (var entry in runtimeStatsMap) {
+ result.addPair(entry, runtimeStatsMap[entry]);
}
- result.addPair('Total', {time: Number(totalTime).toFixed(2),
- count: totalCount});
}
tr.mre.FunctionRegistry.register(v8CallStatsDump);
« 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