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

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

Issue 2639993002: Adds runtimeStatsTotalMetric to collect v8 metrics and bucket them based on UE. (Closed)
Patch Set: Rebased the patch. Created 3 years, 10 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
Index: tracing/tracing/metrics/v8/runtime_stats_metric_test.html
diff --git a/tracing/tracing/metrics/v8/runtime_stats_metric_test.html b/tracing/tracing/metrics/v8/runtime_stats_metric_test.html
index f56b0059fb9310a2c096197be8b509c76c93c035..83e84190fed05d52ad000bf9ef88a01337ed3347 100644
--- a/tracing/tracing/metrics/v8/runtime_stats_metric_test.html
+++ b/tracing/tracing/metrics/v8/runtime_stats_metric_test.html
@@ -309,5 +309,253 @@ tr.b.unittest.testSuite(function() {
checkRuntimeHistogram_(values, 'LoadIC_Miss', 4, 0.044);
checkRuntimeHistogram_(values, 'API_Object_Get', 18, 0.198);
});
+
+ test('runtimeStatsMetricBucketOnUE', function() {
+ // Test that v8 statistics are properly bucketed when UEs overlap.
+ // The renderer thread timeline looks like:
+ //
+ // * * [ V8 ] * [ V8 ] * [ V8 ] * [ V8 ] * [ V8 ] *
+ // | | | | | | |
+ // | | | | | | |
+ // v v v v v v v
+ // First LoadStart LoadEnd AnimStart RespEnd AnimEnd IdleEnd
+ // nav RespStart IdleStart
+ // 200 300 1000 2000 2100 3000 3500
+
+ var model = tr.c.TestUtils.newModel(function(model) {
+ var rendererProcess = model.getOrCreateProcess(1984);
+ var mainThread = rendererProcess.getOrCreateThread(2);
+ mainThread.name = 'CrRendererMain';
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'blink.user_timing',
+ title: 'navigationStart',
+ start: 200,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
+
+ // Add User expectations.
+ model.userModel.expectations.push(new tr.model.um.LoadExpectation(
+ model, tr.model.um.LOAD_SUBTYPE_NAMES.SUCCESSFUL, 0, 1000));
+
+ model.userModel.expectations.push(new tr.model.um.ResponseExpectation(
+ model, tr.importer.INITIATOR_TYPE.SCROLL, 1000, 1100));
+
+ model.userModel.expectations.push(new tr.model.um.AnimationExpectation(
+ model, tr.importer.INITIATOR_TYPE.VIDEO, 2000, 1000));
+
+ model.userModel.expectations.push(new tr.model.um.IdleExpectation(
+ model, 3000, 500));
+
+ // Add V8 ThreadSlices corresponding to Load UE.
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'v8',
+ title: 'V8.newInstance',
+ type: tr.e.v8.V8ThreadSlice,
+ start: 300,
+ duration: 600,
+ args: {
+ 'runtime-call-stats': {
+ JS_Execution: [1, 10],
+ HandleApiCall: [2, 11],
+ CompileFullCode: [3, 12],
+ LoadIC_Miss: [4, 13],
+ ParseLazy: [5, 14],
+ OptimizeCode: [6, 15],
+ FunctionCallback: [7, 16],
+ AllocateInTargetSpace: [8, 17],
+ API_Object_Get: [9, 18]
+ }
+ }
+ }));
+
+ // Add V8 Thread slices corresponding to Response UE
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'v8',
+ title: 'V8.Execute',
+ type: tr.e.v8.V8ThreadSlice,
+ start: 1000,
+ duration: 800,
+ args: {
+ 'runtime-call-stats': {
+ JS_Execution: [1, 11],
+ HandleApiCall: [2, 22],
+ CompileFullCode: [3, 33],
+ LoadIC_Miss: [4, 44],
+ ParseLazy: [5, 55],
+ OptimizeCode: [6, 66],
+ FunctionCallback: [7, 77],
+ AllocateInTargetSpace: [8, 88],
+ API_Object_Get: [9, 99]
+ }
+ }
+ }));
+
+ // V8 slices in the overlap range of animation + response
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'v8',
+ title: 'V8.Execute',
+ type: tr.e.v8.V8ThreadSlice,
+ start: 2000,
+ duration: 99,
+ args: {
+ 'runtime-call-stats': {
+ JS_Execution: [1, 1],
+ HandleApiCall: [2, 2],
+ CompileFunctionLiteral: [3, 7],
+ LoadIC_Miss: [4, 4],
+ ParseLazy: [5, 5],
+ OptimizeCode: [6, 6],
+ FunctionCallback: [7, 7],
+ AllocateInTargetSpace: [8, 8],
+ API_Object_Get: [9, 9]
+ }
+ }
+ }));
+
+ // V8 slices in animation UE range.
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'v8',
+ title: 'V8.Execute',
+ type: tr.e.v8.V8ThreadSlice,
+ start: 2200,
+ duration: 700,
+ args: {
+ 'runtime-call-stats': {
+ JS_Execution: [1, 1],
+ HandleApiCall: [2, 2],
+ CompileFullCode: [3, 3],
+ StoreIC_Miss: [4, 4],
+ ParseLazy: [5, 5],
+ OptimizeCode: [6, 6],
+ FunctionCallback: [7, 7],
+ AllocateInTargetSpace: [8, 8],
+ API_Object_Get: [9, 9]
+ }
+ }
+ }));
+
+ // Add V8 slices corresponding to Idle UE.
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'v8',
+ title: 'V8.Execute',
+ type: tr.e.v8.V8ThreadSlice,
+ start: 3001,
+ duration: 499,
+ args: {
+ 'runtime-call-stats': {
+ JS_Execution: [1, 11],
+ HandleApiCall: [2, 22],
+ CompileFullCode: [3, 33],
+ LoadIC_Miss: [4, 44],
+ ParseLazy: [5, 55],
+ OptimizeCode: [6, 66],
+ FunctionCallback: [7, 77],
+ AllocateInTargetSpace: [8, 88],
+ API_Object_Get: [9, 99]
+ }
+ }
+ }));
+ });
+
+ var histograms = new tr.v.HistogramSet();
+ tr.metrics.v8.runtimeStatsTotalMetric(histograms, model);
+ assert.equal(histograms.length, 120);
+
+ // Check total:
+ checkRuntimeHistogram_(histograms, 'Any_IC', 20, 0.109);
+ checkRuntimeHistogram_(histograms, 'Any_API', 45, 0.234);
+ checkRuntimeHistogram_(histograms, 'Any_Total', 225, 1.21);
+
+ // Check Load bucket:
+ checkRuntimeHistogram_(histograms, 'Load_Parse', 5, 0.014);
+ checkRuntimeHistogram_(histograms, 'Load_JavaScript', 1, 0.01);
+
+ // Check Response bucket:
+ checkRuntimeHistogram_(histograms, 'Response_Parse', 10, 0.06);
+ checkRuntimeHistogram_(histograms, 'Response_Compile', 6, 0.04);
+
+ // Check Animation bucket:
+ checkRuntimeHistogram_(histograms, 'Animation_Parse', 10, 0.01);
+
+ // Check Idle bucket:
+ checkRuntimeHistogram_(histograms, 'Idle_Parse', 5, 0.055);
+ });
+
+ test('runtimeStatsMetricTotalNoUE', function() {
+ // Test that total v8 count works even without UE.
+ // The renderer thread timeline looks like:
+ //
+ // * [V8.NewInstance] * [ V8.Execute ] *
+ // |
+ // v
+ // First navigation
+ // 200
+
+ var model = tr.c.TestUtils.newModel(function(model) {
+ var rendererProcess = model.getOrCreateProcess(1984);
+ var mainThread = rendererProcess.getOrCreateThread(2);
+ mainThread.name = 'CrRendererMain';
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'blink.user_timing',
+ title: 'navigationStart',
+ start: 200,
+ duration: 0.0,
+ args: {frame: '0xdeadbeef'}
+ }));
+
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'v8',
+ title: 'V8.newInstance',
+ type: tr.e.v8.V8ThreadSlice,
+ start: 300,
+ duration: 600,
+ args: {
+ 'runtime-call-stats': {
+ JS_Execution: [1, 10],
+ HandleApiCall: [2, 11],
+ CompileFullCode: [3, 12],
+ StoreIC_Miss: [4, 13],
+ ParseLazy: [5, 14],
+ OptimizeCode: [6, 15],
+ FunctionCallback: [7, 16],
+ AllocateInTargetSpace: [8, 17],
+ API_Object_Get: [9, 18]
+ }
+ }
+ }));
+
+ mainThread.sliceGroup.pushSlice(tr.c.TestUtils.newSliceEx({
+ cat: 'v8',
+ title: 'V8.Execute',
+ type: tr.e.v8.V8ThreadSlice,
+ start: 1100,
+ duration: 800,
+ args: {
+ 'runtime-call-stats': {
+ JS_Execution: [1, 11],
+ HandleApiCall: [2, 22],
+ CompileFullCode: [3, 33],
+ LoadIC_Miss: [4, 44],
+ ParseFunctionLiteral: [5, 55],
+ OptimizeCode: [6, 66],
+ FunctionCallback: [7, 77],
+ AllocateInTargetSpace: [8, 88],
+ API_Context_New: [9, 99]
+ }
+ }
+ }));
+ });
+
+ var histograms = new tr.v.HistogramSet();
+ tr.metrics.v8.runtimeStatsTotalMetric(histograms, model);
+ assert.equal(histograms.length, 24);
+
+ // Check total:
+ checkRuntimeHistogram_(histograms, 'Any_IC', 8, 0.057);
+ checkRuntimeHistogram_(histograms, 'Any_API', 18, 0.117);
+ checkRuntimeHistogram_(histograms, 'Any_Parse', 10, 0.069);
+ checkRuntimeHistogram_(histograms, 'Any_Total', 90, 0.621);
+ });
});
</script>

Powered by Google App Engine
This is Rietveld 408576698