1 """Benchmark the turnaround time starting a debugger and run to the breakpoint with lldb vs. gdb."""
5 from lldbsuite
.test
.lldbbench
import *
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import configuration
9 from lldbsuite
.test
import lldbutil
12 class CompileRunToBreakpointBench(BenchBase
):
15 self
.exe
= lldbtest_config
.lldbExec
16 self
.function
= "Driver::MainLoop()"
26 bugnumber
="llvm.org/pr22274: need a pexpect replacement for windows",
28 def test_run_lldb_then_gdb(self
):
29 """Benchmark turnaround time with lldb vs. gdb."""
31 self
.run_lldb_turnaround(self
.exe
, self
.function
, self
.count
)
32 print("lldb turnaround benchmark:", self
.stopwatch
)
33 self
.run_gdb_turnaround(self
.exe
, self
.function
, self
.count
)
34 print("gdb turnaround benchmark:", self
.stopwatch
)
35 print("lldb_avg/gdb_avg: %f" % (self
.lldb_avg
/ self
.gdb_avg
))
37 def run_lldb_turnaround(self
, exe
, function
, count
):
41 prompt
= self
.child_prompt
43 # So that the child gets torn down after the test.
44 self
.child
= pexpect
.spawn(
45 "%s %s %s" % (lldbtest_config
.lldbExec
, self
.lldbOption
, exe
)
49 # Turn on logging for what the child sends back.
51 child
.logfile_read
= sys
.stdout
53 child
.expect_exact(prompt
)
54 child
.sendline("breakpoint set -F %s" % function
)
55 child
.expect_exact(prompt
)
57 child
.expect_exact(prompt
)
59 # Set self.child_prompt, which is "(lldb) ".
60 self
.child_prompt
= "(lldb) "
61 # Reset the stopwatch now.
62 self
.stopwatch
.reset()
64 for i
in range(count
+ 1):
65 # Ignore the first invoke lldb and run to the breakpoint turnaround
73 self
.child
.sendline("quit")
75 self
.child
.expect(pexpect
.EOF
)
79 self
.lldb_avg
= self
.stopwatch
.avg()
82 def run_gdb_turnaround(self
, exe
, function
, count
):
86 prompt
= self
.child_prompt
88 # So that the child gets torn down after the test.
89 self
.child
= pexpect
.spawn("gdb --nx %s" % exe
)
92 # Turn on logging for what the child sends back.
94 child
.logfile_read
= sys
.stdout
96 child
.expect_exact(prompt
)
97 child
.sendline("break %s" % function
)
98 child
.expect_exact(prompt
)
100 child
.expect_exact(prompt
)
102 # Set self.child_prompt, which is "(gdb) ".
103 self
.child_prompt
= "(gdb) "
104 # Reset the stopwatch now.
105 self
.stopwatch
.reset()
107 for i
in range(count
+ 1):
108 # Ignore the first invoke lldb and run to the breakpoint turnaround
116 self
.child
.sendline("quit")
117 self
.child
.expect_exact("The program is running. Exit anyway?")
118 self
.child
.sendline("y")
120 self
.child
.expect(pexpect
.EOF
)
124 self
.gdb_avg
= self
.stopwatch
.avg()