1 """Benchmark the turnaround time starting a debugger and run to the breakpont with lldb vs. gdb."""
3 from __future__ import print_function
8 from lldbsuite.test.lldbbench import *
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import configuration
12 from lldbsuite.test import lldbutil
15 class CompileRunToBreakpointBench(BenchBase):
17 mydir = TestBase.compute_mydir(__file__)
21 self.exe = lldbtest_config.lldbExec
22 self.function = 'Driver::MainLoop()'
32 bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
33 def test_run_lldb_then_gdb(self):
34 """Benchmark turnaround time with lldb vs. gdb."""
36 self.run_lldb_turnaround(self.exe, self.function, self.count)
37 print("lldb turnaround benchmark:", self.stopwatch)
38 self.run_gdb_turnaround(self.exe, self.function, self.count)
39 print("gdb turnaround benchmark:", self.stopwatch)
40 print("lldb_avg/gdb_avg: %f" % (self.lldb_avg / self.gdb_avg))
42 def run_lldb_turnaround(self, exe, function, count):
46 prompt = self.child_prompt
48 # So that the child gets torn down after the test.
49 self.child = pexpect.spawn(
51 (lldbtest_config.lldbExec, self.lldbOption, exe))
54 # Turn on logging for what the child sends back.
56 child.logfile_read = sys.stdout
58 child.expect_exact(prompt)
59 child.sendline('breakpoint set -F %s' % function)
60 child.expect_exact(prompt)
62 child.expect_exact(prompt)
64 # Set self.child_prompt, which is "(lldb) ".
65 self.child_prompt = '(lldb) '
66 # Reset the stopwatch now.
67 self.stopwatch.reset()
69 for i in range(count + 1):
70 # Ignore the first invoke lldb and run to the breakpoint turnaround
78 self.child.sendline('quit')
80 self.child.expect(pexpect.EOF)
84 self.lldb_avg = self.stopwatch.avg()
87 def run_gdb_turnaround(self, exe, function, count):
91 prompt = self.child_prompt
93 # So that the child gets torn down after the test.
94 self.child = pexpect.spawn('gdb --nx %s' % exe)
97 # Turn on logging for what the child sends back.
99 child.logfile_read = sys.stdout
101 child.expect_exact(prompt)
102 child.sendline('break %s' % function)
103 child.expect_exact(prompt)
104 child.sendline('run')
105 child.expect_exact(prompt)
107 # Set self.child_prompt, which is "(gdb) ".
108 self.child_prompt = '(gdb) '
109 # Reset the stopwatch now.
110 self.stopwatch.reset()
112 for i in range(count + 1):
113 # Ignore the first invoke lldb and run to the breakpoint turnaround
121 self.child.sendline('quit')
122 self.child.expect_exact('The program is running. Exit anyway?')
123 self.child.sendline('y')
125 self.child.expect(pexpect.EOF)
129 self.gdb_avg = self.stopwatch.avg()