1"""Test lldb's response time for 'frame variable' command.""" 2 3from __future__ import print_function 4 5 6import sys 7import lldb 8from lldbsuite.test import configuration 9from lldbsuite.test import lldbtest_config 10from lldbsuite.test.decorators import * 11from lldbsuite.test.lldbbench import * 12 13 14class FrameVariableResponseBench(BenchBase): 15 16 def setUp(self): 17 BenchBase.setUp(self) 18 self.exe = lldbtest_config.lldbExec 19 self.break_spec = '-n main' 20 self.count = 20 21 22 @benchmarks_test 23 @no_debug_info_test 24 @expectedFailureAll( 25 oslist=["windows"], 26 bugnumber="llvm.org/pr22274: need a pexpect replacement for windows") 27 def test_startup_delay(self): 28 """Test response time for the 'frame variable' command.""" 29 print() 30 self.run_frame_variable_bench(self.exe, self.break_spec, self.count) 31 print("lldb frame variable benchmark:", self.stopwatch) 32 33 def run_frame_variable_bench(self, exe, break_spec, count): 34 import pexpect 35 # Set self.child_prompt, which is "(lldb) ". 36 self.child_prompt = '(lldb) ' 37 prompt = self.child_prompt 38 39 # Reset the stopwatchs now. 40 self.stopwatch.reset() 41 for i in range(count): 42 # So that the child gets torn down after the test. 43 self.child = pexpect.spawn( 44 '%s %s %s' % 45 (lldbtest_config.lldbExec, self.lldbOption, exe)) 46 child = self.child 47 48 # Turn on logging for what the child sends back. 49 if self.TraceOn(): 50 child.logfile_read = sys.stdout 51 52 # Set our breakpoint. 53 child.sendline('breakpoint set %s' % break_spec) 54 child.expect_exact(prompt) 55 56 # Run the target and expect it to be stopped due to breakpoint. 57 child.sendline('run') # Aka 'process launch'. 58 child.expect_exact(prompt) 59 60 with self.stopwatch: 61 # Measure the 'frame variable' response time. 62 child.sendline('frame variable') 63 child.expect_exact(prompt) 64 65 child.sendline('quit') 66 try: 67 self.child.expect(pexpect.EOF) 68 except: 69 pass 70 71 # The test is about to end and if we come to here, the child process has 72 # been terminated. Mark it so. 73 self.child = None 74