1""" 2Test lldb data formatter subsystem. 3""" 4 5from __future__ import print_function 6 7 8import lldb 9from lldbsuite.test.decorators import * 10from lldbsuite.test.lldbbench import * 11from lldbsuite.test.lldbtest import * 12from lldbsuite.test import lldbutil 13 14 15class TestBenchmarkLibcxxList(BenchBase): 16 17 mydir = TestBase.compute_mydir(__file__) 18 19 @benchmarks_test 20 def test_run_command(self): 21 """Benchmark the std::list data formatter (libc++)""" 22 self.build() 23 self.data_formatter_commands() 24 25 def setUp(self): 26 # Call super's setUp(). 27 BenchBase.setUp(self) 28 29 def data_formatter_commands(self): 30 """Benchmark the std::list data formatter (libc++)""" 31 self.runCmd("file " + self.getBuildArtifact("a.out"), 32 CURRENT_EXECUTABLE_SET) 33 34 bkpt = self.target().FindBreakpointByID( 35 lldbutil.run_break_set_by_source_regexp( 36 self, "break here")) 37 38 self.runCmd("run", RUN_SUCCEEDED) 39 40 # The stop reason of the thread should be breakpoint. 41 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 42 substrs=['stopped', 43 'stop reason = breakpoint']) 44 45 # This is the function to remove the custom formats in order to have a 46 # clean slate for the next test case. 47 def cleanup(): 48 self.runCmd('type format clear', check=False) 49 self.runCmd('type summary clear', check=False) 50 self.runCmd('type filter clear', check=False) 51 self.runCmd('type synth clear', check=False) 52 self.runCmd( 53 "settings set target.max-children-count 256", 54 check=False) 55 56 # Execute the cleanup function during test case tear down. 57 self.addTearDownHook(cleanup) 58 59 sw = Stopwatch() 60 61 sw.start() 62 self.expect('frame variable -A list', substrs=['[300]', '300']) 63 sw.stop() 64 65 print("time to print: %s" % (sw)) 66