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

Side by Side Diff: tracing/tracing/metrics/v8/runtime_stats_metric_test.html

Issue 2415963002: [V8][Metric] Initial implementation of the RuntimeStatsMetric (Closed)
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/tracing/core/test_utils.html">
9 <link rel="import" href="/tracing/extras/v8/v8_thread_slice.html">
10 <link rel="import" href="/tracing/metrics/v8/runtime_stats_metric.html">
11 <link rel="import" href="/tracing/value/histogram.html">
12 <link rel="import" href="/tracing/value/value_set.html">
13
14 <script>
15 'use strict';
16
17 tr.b.unittest.testSuite(function() {
18 function checkRuntimeHistogram_(values, name, count, duration,
19 breakdownHistograms) {
20 var countHistogram = tr.b.getOnlyElement(values.getValuesNamed(name +
21 ':count'));
22 assert.equal(tr.b.getOnlyElement(countHistogram.sampleValues), count);
23 var durationHistogram = tr.b.getOnlyElement(values.getValuesNamed(name +
24 ':duration'));
25 assert.equal(tr.b.getOnlyElement(durationHistogram.sampleValues), duration);
26
27 if (breakdownHistograms === undefined) return;
28 var countBin = tr.b.getOnlyElement(countHistogram.allBins.filter(
29 bin => bin.diagnosticMaps.length > 0));
30 var durationBin = tr.b.getOnlyElement(durationHistogram.allBins.filter(
31 bin => bin.diagnosticMaps.length > 0));
32 for (var name of breakdownHistograms) {
33 assert.notEqual(tr.b.getOnlyElement(countBin.diagnosticMaps)
34 .get('samples').get(name + ':count'), undefined);
35 assert.notEqual(tr.b.getOnlyElement(durationBin.diagnosticMaps)
36 .get('samples').get(name + ':duration'), undefined);
37 }
38 }
39
40 test('runtimeStatsMetric', function() {
41 // The renderer thread timeline looks like:
42 //
43 // * [V8.NewInstance] * [ V8.Execute ] * ...[V8.Ignored]
44 // | | |
45 // | | |
46 // v v v
47 // First navigation FMP TTI
48 // 200 9200 15400
49 var model = tr.c.TestUtils.newModel(function(model) {
50 var rendererProcess = model.getOrCreateProcess(1984);
51 var mainThread = rendererProcess.getOrCreateThread(2);
52 mainThread.name = 'CrRendererMain';
53 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
54 cat: 'blink.user_timing',
55 title: 'navigationStart',
56 start: 200,
57 duration: 0.0,
58 args: {frame: '0xdeadbeef'}
59 }));
60 rendererProcess.objects.addSnapshot('ptr', 'loading', 'FrameLoader', 300,
61 {isLoadingMainFrame: true, frame: {id_ref: '0xdeadbeef'},
62 documentLoaderURL: 'http://example.com'});
63
64 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
65 cat: 'v8',
66 title: 'V8.newInstance',
67 type: tr.e.v8.V8ThreadSlice,
68 start: 12555,
69 duration: 990,
70 args: {
71 'runtime-call-stats': {
72 JS_Execution: [1, 11],
73 HandleApiCall: [2, 22],
74 CompileFullCode: [3, 33],
75 LoadIC_Miss: [4, 44],
76 ParseLazy: [5, 55],
77 OptimizeCode: [6, 66],
78 FunctionCallback: [7, 77],
79 AllocateInTargetSpace: [8, 88],
80 API_Object_Get: [9, 99]
81 }
82 }
83 }));
84
85 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
86 cat: 'loading',
87 title: 'firstMeaningfulPaintCandidate',
88 start: 9180,
89 duration: 0.0,
90 args: {frame: '0xdeadbeef'}
91 }));
92
93 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
94 cat: 'loading',
95 title: 'firstMeaningfulPaintCandidate',
96 start: 9200,
97 duration: 0.0,
98 args: {frame: '0xdeadbeef'}
99 }));
100
101 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
102 cat: 'toplevel',
103 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
104 start: 9350,
105 duration: 100,
106 }));
107
108 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
109 cat: 'toplevel',
110 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
111 start: 11150,
112 duration: 100,
113 }));
114
115 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
116 cat: 'toplevel',
117 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
118 start: 12550,
119 duration: 1000,
120 }));
121
122 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
123 cat: 'v8',
124 title: 'V8.Execute',
125 type: tr.e.v8.V8ThreadSlice,
126 start: 12555,
127 duration: 990,
128 args: {
129 'runtime-call-stats': {
130 JS_Execution: [1, 11],
131 HandleApiCall: [2, 22],
132 CompileFullCode: [3, 33],
133 StoreIC_Miss: [4, 44],
134 ParseLazy: [5, 55],
135 OptimizeCode: [6, 66],
136 FunctionCallback: [7, 77],
137 AllocateInTargetSpace: [8, 88],
138 API_Object_Get: [9, 99]
139 }
140 }
141 }));
142
143 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
144 cat: 'toplevel',
145 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
146 start: 14950,
147 duration: 500,
148 }));
149
150 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
151 cat: 'toplevel',
152 title: 'TaskQueueManager::ProcessTaskFromWorkQueue',
153 start: 22150,
154 duration: 10,
155 }));
156
157 mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
158 cat: 'v8',
159 title: 'V8.Ignored',
160 type: tr.e.v8.V8ThreadSlice,
161 start: 30000,
162 duration: 1000,
163 args: {
164 'runtime-call-stats': {
165 JS_Execution: [1, 11],
166 HandleApiCall: [2, 22],
167 CompileFullCode: [3, 33],
168 LoadIC_Miss: [4, 44],
169 ParseLazy: [5, 55],
170 OptimizeCode: [6, 66],
171 FunctionCallback: [7, 77],
172 AllocateInTargetSpace: [8, 88],
173 API_Object_Get: [9, 99]
174 }
175 }
176 }));
177 });
178
179 var values = new tr.v.ValueSet();
180 tr.metrics.v8.runtimeStatsMetric(values, model);
181 assert.equal(values.length, 40);
182 assert.equal(values.sourceValues.length, 20);
183
184 // A few of the top level ones.
185 checkRuntimeHistogram_(values, 'IC', 8, 0.088, ['LoadIC_Miss',
186 'StoreIC_Miss']);
187 checkRuntimeHistogram_(values, 'API', 18, 0.198, ['API_Object_Get']);
188 checkRuntimeHistogram_(values, 'Total', 90, 0.99);
189 // And a couple of the lower level ones
190 checkRuntimeHistogram_(values, 'LoadIC_Miss', 4, 0.044);
191 checkRuntimeHistogram_(values, 'API_Object_Get', 18, 0.198);
192 });
193 });
194 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/metrics/v8/runtime_stats_metric.html ('k') | tracing/tracing/ui/extras/v8/runtime_call_stats_table.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698