blob: 83674c6ff240596f687d67669b76a69e43b7c4fd [file] [log] [blame]
Enrico Granata7a2421092015-01-22 19:33:53 +00001"""
2Test lldb data formatter subsystem.
3"""
4
Zachary Turner77db4a82015-10-22 20:06:20 +00005import lldb_shared
6
Enrico Granata7a2421092015-01-22 19:33:53 +00007import os, time
Enrico Granata7a2421092015-01-22 19:33:53 +00008import lldb
9from lldbbench import *
10import lldbutil
11
12class TestBenchmarkContinue(BenchBase):
13
14 mydir = TestBase.compute_mydir(__file__)
15
16 @benchmarks_test
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000017 def test_run_command(self):
Enrico Granata7a2421092015-01-22 19:33:53 +000018 """Benchmark different ways to continue a process"""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000019 self.build()
Enrico Granata7a2421092015-01-22 19:33:53 +000020 self.data_formatter_commands()
21
22 def setUp(self):
23 # Call super's setUp().
24 BenchBase.setUp(self)
25
26 def data_formatter_commands(self):
27 """Benchmark different ways to continue a process"""
28 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
29
30 bkpt = self.target().FindBreakpointByID(lldbutil.run_break_set_by_source_regexp (self, "// break here"))
31
Sean Callanan05834cd2015-07-01 23:56:30 +000032 self.runCmd("run", RUN_SUCCEEDED)
Enrico Granata7a2421092015-01-22 19:33:53 +000033
34 # The stop reason of the thread should be breakpoint.
35 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
36 substrs = ['stopped',
37 'stop reason = breakpoint'])
38
39 # This is the function to remove the custom formats in order to have a
40 # clean slate for the next test case.
41 def cleanup():
42 self.runCmd('type format clear', check=False)
43 self.runCmd('type summary clear', check=False)
44 self.runCmd('type filter clear', check=False)
45 self.runCmd('type synth clear', check=False)
46 self.runCmd("settings set target.max-children-count 256", check=False)
47
48 # Execute the cleanup function during test case tear down.
49 self.addTearDownHook(cleanup)
50
51 runCmd_sw = Stopwatch()
52 lldbutil_sw = Stopwatch()
53
54 for i in range(0,15):
55 runCmd_sw.start()
56 self.runCmd("continue")
57 runCmd_sw.stop()
58
59 for i in range(0,15):
60 lldbutil_sw.start()
61 lldbutil.continue_to_breakpoint(self.process(), bkpt)
62 lldbutil_sw.stop()
63
64 print "runCmd: %s\nlldbutil: %s" % (runCmd_sw,lldbutil_sw)