Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright (C) 2013-2020 Free Software Foundation, Inc. |
6dbb6798 YQ |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # This test case is to test the speed of GDB when it is handling the | |
17 | # shared libraries of inferior are loaded and unloaded. | |
18 | ||
19 | from perftest import perftest | |
20 | from perftest import measure | |
21 | ||
22 | class SolibLoadUnload1(perftest.TestCaseWithBasicMeasurements): | |
23 | def __init__(self, solib_count, measure_load): | |
24 | if measure_load: | |
25 | name = "solib_load" | |
26 | else: | |
27 | name = "solib_unload" | |
28 | # We want to measure time in this test. | |
29 | super (SolibLoadUnload1, self).__init__ (name) | |
30 | self.solib_count = solib_count | |
31 | self.measure_load = measure_load | |
32 | ||
33 | def warm_up(self): | |
34 | do_test_load = "call do_test_load (%d)" % self.solib_count | |
35 | do_test_unload = "call do_test_unload (%d)" % self.solib_count | |
36 | gdb.execute(do_test_load) | |
37 | gdb.execute(do_test_unload) | |
38 | ||
39 | def execute_test(self): | |
40 | num = self.solib_count | |
41 | iteration = 5; | |
42 | ||
43 | while num > 0 and iteration > 0: | |
44 | # Do inferior calls to do_test_load and do_test_unload in pairs, | |
45 | # but measure differently. | |
46 | if self.measure_load: | |
47 | do_test_load = "call do_test_load (%d)" % num | |
48 | func = lambda: gdb.execute (do_test_load) | |
49 | ||
50 | self.measure.measure(func, num) | |
51 | ||
52 | do_test_unload = "call do_test_unload (%d)" % num | |
53 | gdb.execute (do_test_unload) | |
54 | ||
55 | else: | |
56 | do_test_load = "call do_test_load (%d)" % num | |
57 | gdb.execute (do_test_load) | |
58 | ||
59 | do_test_unload = "call do_test_unload (%d)" % num | |
60 | func = lambda: gdb.execute (do_test_unload) | |
61 | ||
62 | self.measure.measure(func, num) | |
63 | ||
64 | num = num / 2 | |
65 | iteration -= 1 | |
66 | ||
67 | class SolibLoadUnload(object): | |
68 | def __init__(self, solib_count): | |
69 | self.solib_count = solib_count; | |
70 | ||
71 | def run(self): | |
72 | SolibLoadUnload1(self.solib_count, True).run() | |
73 | SolibLoadUnload1(self.solib_count, False).run() |