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

Side by Side Diff: test/inspector/cpu-profiler/coverage.js

Issue 2715833003: [inspector] move coverage related methods to profiler (Closed)
Patch Set: rebased 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var source = 5 var source =
6 ` 6 `
7 function fib(x) { 7 function fib(x) {
8 if (x < 2) return 1; 8 if (x < 2) return 1;
9 return fib(x-1) + fib(x-2); 9 return fib(x-1) + fib(x-2);
10 } 10 }
11 (function iife() { 11 (function iife() {
12 return 1; 12 return 1;
13 })(); 13 })();
14 fib(5); 14 fib(5);
15 `; 15 `;
16 16
17 print("Test collecting code coverage data with Runtime.collectCoverage."); 17 print("Test collecting code coverage data with Profiler.collectCoverage.");
18 18
19 function ClearAndGC() { 19 function ClearAndGC() {
20 return Protocol.Runtime.evaluate({ expression: "fib = null;" }) 20 return Protocol.Runtime.evaluate({ expression: "fib = null;" })
21 .then(() => Protocol.HeapProfiler.enable()) 21 .then(() => Protocol.HeapProfiler.enable())
22 .then(() => Protocol.HeapProfiler.collectGarbage()) 22 .then(() => Protocol.HeapProfiler.collectGarbage())
23 .then(() => Protocol.HeapProfiler.disable()); 23 .then(() => Protocol.HeapProfiler.disable());
24 } 24 }
25 25
26 function LogSorted(message) { 26 function LogSorted(message) {
27 message.result.result.sort((a, b) => parseInt(a.scriptId) - parseInt(b.scriptI d)); 27 message.result.result.sort((a, b) => parseInt(a.scriptId) - parseInt(b.scriptI d));
28 return InspectorTest.logMessage(message); 28 return InspectorTest.logMessage(message);
29 } 29 }
30 30
31 InspectorTest.runTestSuite([ 31 InspectorTest.runTestSuite([
32 function testPreciseCoverage(next) 32 function testPreciseCoverage(next)
33 { 33 {
34 Protocol.Runtime.enable() 34 Protocol.Runtime.enable()
35 .then(Protocol.Runtime.startPreciseCoverage) 35 .then(Protocol.Profiler.enable)
36 .then(Protocol.Profiler.startPreciseCoverage)
36 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "1", persistScript: true })) 37 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "1", persistScript: true }))
37 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) 38 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
38 .then(ClearAndGC) 39 .then(ClearAndGC)
39 .then(InspectorTest.logMessage) 40 .then(InspectorTest.logMessage)
40 .then(Protocol.Runtime.takePreciseCoverage) 41 .then(Protocol.Profiler.takePreciseCoverage)
41 .then(LogSorted) 42 .then(LogSorted)
42 .then(Protocol.Runtime.takePreciseCoverage) 43 .then(Protocol.Profiler.takePreciseCoverage)
43 .then(LogSorted) 44 .then(LogSorted)
44 .then(ClearAndGC) 45 .then(ClearAndGC)
45 .then(Protocol.Runtime.stopPreciseCoverage) 46 .then(Protocol.Profiler.stopPreciseCoverage)
47 .then(Protocol.Profiler.disable)
46 .then(Protocol.Runtime.disable) 48 .then(Protocol.Runtime.disable)
47 .then(next); 49 .then(next);
48 }, 50 },
49 function testPreciseCoverageFail(next) 51 function testPreciseCoverageFail(next)
50 { 52 {
51 Protocol.Runtime.enable() 53 Protocol.Runtime.enable()
54 .then(Protocol.Profiler.enable)
52 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "2", persistScript: true })) 55 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "2", persistScript: true }))
53 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) 56 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
54 .then(InspectorTest.logMessage) 57 .then(InspectorTest.logMessage)
55 .then(ClearAndGC) 58 .then(ClearAndGC)
56 .then(Protocol.Runtime.takePreciseCoverage) 59 .then(Protocol.Profiler.takePreciseCoverage)
57 .then(InspectorTest.logMessage) 60 .then(InspectorTest.logMessage)
58 .then(ClearAndGC) 61 .then(ClearAndGC)
62 .then(Protocol.Profiler.disable)
59 .then(Protocol.Runtime.disable) 63 .then(Protocol.Runtime.disable)
60 .then(next); 64 .then(next);
61 }, 65 },
62 function testBestEffortCoverage(next) 66 function testBestEffortCoverage(next)
63 { 67 {
64 Protocol.Runtime.enable() 68 Protocol.Runtime.enable()
65 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "3", persistScript: true })) 69 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "3", persistScript: true }))
66 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) 70 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
67 .then(InspectorTest.logMessage) 71 .then(InspectorTest.logMessage)
68 .then(ClearAndGC) 72 .then(ClearAndGC)
69 .then(Protocol.Runtime.getBestEffortCoverage) 73 .then(Protocol.Profiler.getBestEffortCoverage)
70 .then(LogSorted) 74 .then(LogSorted)
71 .then(Protocol.Runtime.getBestEffortCoverage) 75 .then(Protocol.Profiler.getBestEffortCoverage)
72 .then(LogSorted) 76 .then(LogSorted)
73 .then(ClearAndGC) 77 .then(ClearAndGC)
74 .then(Protocol.Runtime.disable) 78 .then(Protocol.Runtime.disable)
75 .then(next); 79 .then(next);
76 }, 80 },
77 function testBestEffortCoveragePrecise(next) 81 function testBestEffortCoveragePrecise(next)
78 { 82 {
79 Protocol.Runtime.enable() 83 Protocol.Runtime.enable()
80 .then(Protocol.Runtime.startPreciseCoverage) 84 .then(Protocol.Profiler.enable)
85 .then(Protocol.Profiler.startPreciseCoverage)
81 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "4", persistScript: true })) 86 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "4", persistScript: true }))
82 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) 87 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
83 .then(InspectorTest.logMessage) 88 .then(InspectorTest.logMessage)
84 .then(ClearAndGC) 89 .then(ClearAndGC)
85 .then(Protocol.Runtime.getBestEffortCoverage) 90 .then(Protocol.Profiler.getBestEffortCoverage)
86 .then(LogSorted) 91 .then(LogSorted)
87 .then(Protocol.Runtime.getBestEffortCoverage) 92 .then(Protocol.Profiler.getBestEffortCoverage)
88 .then(LogSorted) 93 .then(LogSorted)
89 .then(ClearAndGC) 94 .then(ClearAndGC)
90 .then(Protocol.Runtime.stopPreciseCoverage) 95 .then(Protocol.Profiler.stopPreciseCoverage)
96 .then(Protocol.Profiler.disable)
91 .then(Protocol.Runtime.disable) 97 .then(Protocol.Runtime.disable)
92 .then(next); 98 .then(next);
93 }, 99 },
94 ]); 100 ]);
OLDNEW
« no previous file with comments | « src/inspector/v8-runtime-agent-impl.cc ('k') | test/inspector/cpu-profiler/coverage-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698