"""Test lldb's response time for 'frame variable' command."""
import sys
import lldb
from lldbsuite.test import configuration
from lldbsuite.test import lldbtest_config
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbbench import *
class FrameVariableResponseBench(BenchBase):
def setUp(self):
BenchBase.setUp(self)
self.exe = lldbtest_config.lldbExec
self.break_spec = "-n main"
self.count = 20
@benchmarks_test
@no_debug_info_test
@add_test_categories(["pexpect"])
def test_startup_delay(self):
"""Test response time for the 'frame variable' command."""
print()
self.run_frame_variable_bench(self.exe, self.break_spec, self.count)
print("lldb frame variable benchmark:", self.stopwatch)
def run_frame_variable_bench(self, exe, break_spec, count):
import pexpect
self.child_prompt = "(lldb) "
prompt = self.child_prompt
self.stopwatch.reset()
for i in range(count):
self.child = pexpect.spawn(
"%s %s %s" % (lldbtest_config.lldbExec, self.lldbOption, exe)
)
child = self.child
if self.TraceOn():
child.logfile_read = sys.stdout
child.sendline("breakpoint set %s" % break_spec)
child.expect_exact(prompt)
child.sendline("run")
child.expect_exact(prompt)
with self.stopwatch:
child.sendline("frame variable")
child.expect_exact(prompt)
child.sendline("quit")
try:
self.child.expect(pexpect.EOF)
except:
pass
self.child = None