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 < 10000000; i++) | |
12 doSomeWork += i; | |
13 return doSomeWork; | |
14 } | |
15 //# sourceURL=test.js`, 7, 26); | |
16 | |
17 function checkProfile(profile) { | |
18 var foundFoo = profile.nodes.some(node => node.callFrame.functionName === 'foo '); | |
alph
2017/06/05 21:10:41
FYI: This has some probability of flaking, as ther
dgozman
2017/06/05 21:50:47
Thanks! I'm staying positive though :)
| |
19 InspectorTest.log(`Found foo() call in profile: ${foundFoo}`); | |
20 } | |
21 | |
22 (async function test() { | |
23 var session1 = await connect(contextGroup, 1); | |
24 var session2 = await connect(contextGroup, 2); | |
25 | |
26 InspectorTest.log('console.profile in 1'); | |
27 await session1.Protocol.Runtime.evaluate({expression: 'console.profile("one"); foo(); console.profileEnd("one");'}); | |
28 InspectorTest.log('console.profile in 2'); | |
29 await session2.Protocol.Runtime.evaluate({expression: 'console.profile("two"); foo(); console.profileEnd("two");'}); | |
30 | |
31 InspectorTest.log('starting in 1'); | |
32 session1.Protocol.Profiler.start(); | |
33 InspectorTest.log('starting in 2'); | |
34 session2.Protocol.Profiler.start(); | |
35 await session1.Protocol.Runtime.evaluate({expression: 'foo();'}); | |
36 | |
37 InspectorTest.log('stopping in 1'); | |
38 var message = await session1.Protocol.Profiler.stop(); | |
39 InspectorTest.log('stopped in 1'); | |
40 checkProfile((message).result.profile); | |
alph
2017/06/05 21:10:41
drop ()
dgozman
2017/06/05 21:50:48
Done.
| |
41 | |
42 InspectorTest.log('stopping in 2'); | |
43 var message = await session2.Protocol.Profiler.stop(); | |
44 InspectorTest.log('stopped in 2'); | |
45 checkProfile((message).result.profile); | |
alph
2017/06/05 21:10:40
drop ()
dgozman
2017/06/05 21:50:48
Done.
| |
46 | |
47 InspectorTest.completeTest(); | |
48 })(); | |
49 | |
50 async function connect(contextGroup, num) { | |
51 var session = contextGroup.connect(); | |
52 session.Protocol.Profiler.onConsoleProfileStarted(message => { | |
53 InspectorTest.log(`console profile started from ${num}: ${message.params.tit le}`); | |
54 }); | |
55 session.Protocol.Profiler.onConsoleProfileFinished(message => { | |
56 InspectorTest.log(`console profile finished from ${num}: ${message.params.ti tle}`); | |
57 checkProfile(message.params.profile); | |
58 }); | |
59 await session.Protocol.Profiler.enable(); | |
60 await session.Protocol.Profiler.setSamplingInterval({interval: 100}); | |
61 return session; | |
62 } | |
OLD | NEW |