summaryrefslogtreecommitdiff
path: root/deps/v8/test/js-perf-test/Inspector/debugger.js
blob: 506d2a3550808180ff751068597134371f1ef081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

(function() {
  function benchy(name, test, testSetup) {
    new BenchmarkSuite(name, [10000], [
      new Benchmark(name, false, false, 0, test, testSetup, TearDown)
    ]);
  }

  benchy('Debugger.paused', DebuggerPaused, Setup);
  benchy('Debugger.getPossibleBreakpoints',
    DebuggerGetPossibleBreakpoints,
    SetupGetPossibleBreakpoints);

  function Setup() {
    SendMessage('Debugger.enable');
    // Force lazy compilation of inspector related scripts.
    SendMessage('Runtime.evaluate', {expression: ''});
  }

  function TearDown() {
    SendMessage('Debugger.disable');
  }

  function DebuggerPaused() {
    for (var i = 0; i < 10; ++i) {
      debugger;
    }
  }

  let scriptId;
  function SetupGetPossibleBreakpoints() {
    Setup();
    let expression = '';
    for (let i = 0; i < 20; ++i) {
      expression += `function foo${i}(){
  if (a) {
    return true;
  } else {
    return false;
  }
}\n`;
    }
    listener = function(msg) {
      if (msg.method === "Debugger.scriptParsed") {
        scriptId = msg.params.scriptId;
        listener = null;
      }
    }
    SendMessage('Runtime.evaluate', {expression});
  }

  function DebuggerGetPossibleBreakpoints() {
    SendMessage('Debugger.getPossibleBreakpoints', {
      start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}
    });
  }
})();