OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 InspectorTest.log('Tests that multiple sessions can record profiles concurrently
.'); |
| 6 |
| 7 var contextGroup = new InspectorTest.ContextGroup(); |
| 8 contextGroup.addScript(` |
| 9 function foo() { |
| 10 var doSomeWork = 1; |
| 11 for (var i = 0; i < 1000; i++) |
| 12 doSomeWork += i; |
| 13 return doSomeWork; |
| 14 } |
| 15 //# sourceURL=test.js`, 7, 26); |
| 16 |
| 17 (async function test() { |
| 18 var session1 = await connect(contextGroup, 1); |
| 19 var session2 = await connect(contextGroup, 2); |
| 20 |
| 21 InspectorTest.log('console.profile in 1'); |
| 22 await session1.Protocol.Runtime.evaluate({expression: 'console.profile("one");
foo(); console.profileEnd("one");'}); |
| 23 InspectorTest.log('console.profile in 2'); |
| 24 await session2.Protocol.Runtime.evaluate({expression: 'console.profile("two");
foo(); console.profileEnd("two");'}); |
| 25 |
| 26 InspectorTest.log('starting in 1'); |
| 27 session1.Protocol.Profiler.start(); |
| 28 InspectorTest.log('starting in 2'); |
| 29 session2.Protocol.Profiler.start(); |
| 30 await session1.Protocol.Runtime.evaluate({expression: 'foo();'}); |
| 31 |
| 32 InspectorTest.log('stopping in 1'); |
| 33 var message = await session1.Protocol.Profiler.stop(); |
| 34 InspectorTest.log('stopped in 1'); |
| 35 |
| 36 InspectorTest.log('stopping in 2'); |
| 37 var message = await session2.Protocol.Profiler.stop(); |
| 38 InspectorTest.log('stopped in 2'); |
| 39 |
| 40 InspectorTest.completeTest(); |
| 41 })(); |
| 42 |
| 43 async function connect(contextGroup, num) { |
| 44 var session = contextGroup.connect(); |
| 45 session.Protocol.Profiler.onConsoleProfileStarted(message => { |
| 46 InspectorTest.log(`console profile started from ${num}: ${message.params.tit
le}`); |
| 47 }); |
| 48 session.Protocol.Profiler.onConsoleProfileFinished(message => { |
| 49 InspectorTest.log(`console profile finished from ${num}: ${message.params.ti
tle}`); |
| 50 }); |
| 51 await session.Protocol.Profiler.enable(); |
| 52 await session.Protocol.Profiler.setSamplingInterval({interval: 100}); |
| 53 return session; |
| 54 } |
OLD | NEW |