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