| OLD | NEW |
| 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 Profiler.collectCoverage."); | 17 InspectorTest.log("Test collecting code coverage data with Profiler.collectCover
age."); |
| 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)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 .then(LogSorted) | 91 .then(LogSorted) |
| 92 .then(Protocol.Profiler.getBestEffortCoverage) | 92 .then(Protocol.Profiler.getBestEffortCoverage) |
| 93 .then(LogSorted) | 93 .then(LogSorted) |
| 94 .then(ClearAndGC) | 94 .then(ClearAndGC) |
| 95 .then(Protocol.Profiler.stopPreciseCoverage) | 95 .then(Protocol.Profiler.stopPreciseCoverage) |
| 96 .then(Protocol.Profiler.disable) | 96 .then(Protocol.Profiler.disable) |
| 97 .then(Protocol.Runtime.disable) | 97 .then(Protocol.Runtime.disable) |
| 98 .then(next); | 98 .then(next); |
| 99 }, | 99 }, |
| 100 ]); | 100 ]); |
| OLD | NEW |