1 """Test lldb's startup delays creating a target, setting a breakpoint, and run to breakpoint stop."""
5 from lldbsuite
.test
import configuration
6 from lldbsuite
.test
import lldbtest_config
7 from lldbsuite
.test
.decorators
import *
8 from lldbsuite
.test
.lldbbench
import *
11 class StartupDelaysBench(BenchBase
):
14 # Create self.stopwatch2 for measuring "set first breakpoint".
15 # The default self.stopwatch is for "create fresh target".
16 self
.stopwatch2
= Stopwatch()
17 # Create self.stopwatch3 for measuring "run to breakpoint".
18 self
.stopwatch3
= Stopwatch()
19 self
.exe
= lldbtest_config
.lldbExec
20 self
.break_spec
= "-n main"
27 bugnumber
="llvm.org/pr22274: need a pexpect replacement for windows",
29 def test_startup_delay(self
):
30 """Test start up delays creating a target, setting a breakpoint, and run to breakpoint stop."""
32 self
.run_startup_delays_bench(self
.exe
, self
.break_spec
, self
.count
)
33 print("lldb startup delay (create fresh target) benchmark:", self
.stopwatch
)
34 print("lldb startup delay (set first breakpoint) benchmark:", self
.stopwatch2
)
35 print("lldb startup delay (run to breakpoint) benchmark:", self
.stopwatch3
)
37 def run_startup_delays_bench(self
, exe
, break_spec
, count
):
40 # Set self.child_prompt, which is "(lldb) ".
41 self
.child_prompt
= "(lldb) "
42 prompt
= self
.child_prompt
44 # Reset the stopwatchs now.
45 self
.stopwatch
.reset()
46 self
.stopwatch2
.reset()
47 for i
in range(count
):
48 # So that the child gets torn down after the test.
49 self
.child
= pexpect
.spawn(
50 "%s %s" % (lldbtest_config
.lldbExec
, self
.lldbOption
)
54 # Turn on logging for what the child sends back.
56 child
.logfile_read
= sys
.stdout
59 # Create a fresh target.
60 child
.sendline("file %s" % exe
) # Aka 'target create'.
61 child
.expect_exact(prompt
)
64 # Read debug info and set the first breakpoint.
65 child
.sendline("breakpoint set %s" % break_spec
)
66 child
.expect_exact(prompt
)
69 # Run to the breakpoint just set.
71 child
.expect_exact(prompt
)
73 child
.sendline("quit")
75 self
.child
.expect(pexpect
.EOF
)
79 # The test is about to end and if we come to here, the child process has
80 # been terminated. Mark it so.