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