Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / benchmarks / startup / TestStartupDelays.py
blobf31a10507ed7efc1a1e82506e673be54f67a4047
1 """Test lldb's startup delays creating a target, setting a breakpoint, and run to breakpoint stop."""
3 import sys
4 import lldb
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):
12 def setUp(self):
13 BenchBase.setUp(self)
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"
21 self.count = 30
23 @benchmarks_test
24 @no_debug_info_test
25 @expectedFailureAll(
26 oslist=["windows"],
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."""
31 print()
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):
38 import pexpect
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)
52 child = self.child
54 # Turn on logging for what the child sends back.
55 if self.TraceOn():
56 child.logfile_read = sys.stdout
58 with self.stopwatch:
59 # Create a fresh target.
60 child.sendline("file %s" % exe) # Aka 'target create'.
61 child.expect_exact(prompt)
63 with self.stopwatch2:
64 # Read debug info and set the first breakpoint.
65 child.sendline("breakpoint set %s" % break_spec)
66 child.expect_exact(prompt)
68 with self.stopwatch3:
69 # Run to the breakpoint just set.
70 child.sendline("run")
71 child.expect_exact(prompt)
73 child.sendline("quit")
74 try:
75 self.child.expect(pexpect.EOF)
76 except:
77 pass
79 # The test is about to end and if we come to here, the child process has
80 # been terminated. Mark it so.
81 self.child = None