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

Unified Diff: tracing/tracing/metrics/v8/runtime_stats_metric.html

Issue 2436193002: Reland of [V8][Metric] Initial implementation of the RuntimeStatsMetric (Closed)
Patch Set: ValueSet --> HistogramSet 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 | « tracing/tracing/metrics/all_metrics.html ('k') | tracing/tracing/metrics/v8/runtime_stats_metric_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/metrics/v8/runtime_stats_metric.html
diff --git a/tracing/tracing/metrics/v8/runtime_stats_metric.html b/tracing/tracing/metrics/v8/runtime_stats_metric.html
new file mode 100644
index 0000000000000000000000000000000000000000..af2f54e0e10ba425e3b22ece8002b8f62a9b36b8
--- /dev/null
+++ b/tracing/tracing/metrics/v8/runtime_stats_metric.html
@@ -0,0 +1,104 @@
+<!DOCTYPE html>
+<!--
+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.
+-->
+
+<link rel="import" href="/tracing/base/range.html">
+<link rel="import" href="/tracing/base/unit.html">
+<link rel="import" href="/tracing/extras/v8/runtime_stats_entry.html">
+<link rel="import" href="/tracing/metrics/metric_registry.html">
+<link rel="import" href="/tracing/metrics/system_health/loading_metric.html">
+<link rel="import" href="/tracing/value/histogram.html">
+
+<script>
+'use strict';
+
+tr.exportTo('tr.metrics.v8', function() {
+ var COUNT_CUSTOM_BOUNDARIES = tr.v.HistogramBinBoundaries
+ .createExponential(1, 1000000, 50);
+ var DURATION_CUSTOM_BOUNDARIES = tr.v.HistogramBinBoundaries
+ .createExponential(0.1, 10000, 50);
+
+ function computeInteractiveTime_(model) {
+ var values = new tr.v.HistogramSet();
+ tr.metrics.sh.loadingMetric(values, model);
+ var ttiEntries = values.getValuesNamed('timeToFirstInteractive');
+
+ // This metric requires traces to contain only one navigation.
+ var histogram = tr.b.getOnlyElement(ttiEntries);
+ var binsWithSampleDiagnosticMaps = histogram.allBins.filter(
+ bin => bin.diagnosticMaps.length > 0);
+ var diagnosticBin = tr.b.getOnlyElement(binsWithSampleDiagnosticMaps);
+ var diagnostic = tr.b.getOnlyElement(diagnosticBin.diagnosticMaps).get(
+ 'Navigation infos');
+ return diagnostic.value.interactive;
+ }
+
+ function createDurationHistogram_(name) {
+ return new tr.v.Histogram(name + ':duration',
+ tr.b.Unit.byName.timeDurationInMs_smallerIsBetter,
+ DURATION_CUSTOM_BOUNDARIES);
+ }
+
+ function createCountHistogram_(name) {
+ return new tr.v.Histogram(name + ':count',
+ tr.b.Unit.byName.count_smallerIsBetter,
+ COUNT_CUSTOM_BOUNDARIES);
+ }
+
+ function convertMicroToMilli_(time) {
+ return tr.b.convertUnit(time,
+ tr.b.UnitScale.Metric.MICRO, tr.b.UnitScale.Metric.MILLI);
+ }
+
+ function computeRuntimeStats(values, model, interactiveTime) {
+ var slices = [...model.getDescendantEvents()].filter(event =>
+ (event instanceof tr.e.v8.V8ThreadSlice) && event.start <=
+ interactiveTime);
+
+ var runtimeGroupCollection = new tr.e.v8.RuntimeStatsGroupCollection();
+ runtimeGroupCollection.addSlices(slices);
+
+ for (var runtimeGroup of runtimeGroupCollection.runtimeGroups) {
+ var durationSamples = new tr.v.d.RelatedHistogramBreakdown();
+ var countSamples = new tr.v.d.RelatedHistogramBreakdown();
+ for (var entry of runtimeGroup.values) {
+ var durationSampleHistogram = createDurationHistogram_(entry.name);
+ durationSampleHistogram.addSample(convertMicroToMilli_(entry.time));
+ durationSamples.set(entry.name + ':duration', durationSampleHistogram);
+ values.addHistogram(durationSampleHistogram);
+
+ var countSampleHistogram = createCountHistogram_(entry.name);
+ countSampleHistogram.addSample(entry.count);
+ countSamples.set(entry.name + ':count', countSampleHistogram);
+ values.addHistogram(countSampleHistogram);
+ }
+
+ var durationHistogram = createDurationHistogram_(runtimeGroup.name);
+ durationHistogram.addSample(convertMicroToMilli_(runtimeGroup.time), {
+ samples: durationSamples
+ });
+ var countHistogram = createCountHistogram_(runtimeGroup.name);
+ countHistogram.addSample(runtimeGroup.count, {
+ samples: countSamples
+ });
+
+ values.addHistogram(durationHistogram);
+ values.addHistogram(countHistogram);
+ }
+ }
+
+ function runtimeStatsMetric(values, model) {
+ var interactiveTime = computeInteractiveTime_(model);
+ computeRuntimeStats(values, model, interactiveTime);
+ }
+
+ tr.metrics.MetricRegistry.register(runtimeStatsMetric);
+
+ return {
+ runtimeStatsMetric: runtimeStatsMetric
+ };
+});
+</script>
« no previous file with comments | « tracing/tracing/metrics/all_metrics.html ('k') | tracing/tracing/metrics/v8/runtime_stats_metric_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698