Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.perf / solib.py
CommitLineData
88b9d363 1# Copyright (C) 2013-2022 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
19from perftest import perftest
20from perftest import measure
21
13123da8 22
6dbb6798
YQ
23class SolibLoadUnload1(perftest.TestCaseWithBasicMeasurements):
24 def __init__(self, solib_count, measure_load):
25 if measure_load:
26 name = "solib_load"
27 else:
28 name = "solib_unload"
29 # We want to measure time in this test.
13123da8 30 super(SolibLoadUnload1, self).__init__(name)
6dbb6798
YQ
31 self.solib_count = solib_count
32 self.measure_load = measure_load
33
34 def warm_up(self):
35 do_test_load = "call do_test_load (%d)" % self.solib_count
36 do_test_unload = "call do_test_unload (%d)" % self.solib_count
37 gdb.execute(do_test_load)
38 gdb.execute(do_test_unload)
39
40 def execute_test(self):
41 num = self.solib_count
13123da8 42 iteration = 5
6dbb6798
YQ
43
44 while num > 0 and iteration > 0:
45 # Do inferior calls to do_test_load and do_test_unload in pairs,
46 # but measure differently.
47 if self.measure_load:
48 do_test_load = "call do_test_load (%d)" % num
13123da8 49 func = lambda: gdb.execute(do_test_load)
6dbb6798
YQ
50
51 self.measure.measure(func, num)
52
53 do_test_unload = "call do_test_unload (%d)" % num
13123da8 54 gdb.execute(do_test_unload)
6dbb6798
YQ
55
56 else:
57 do_test_load = "call do_test_load (%d)" % num
13123da8 58 gdb.execute(do_test_load)
6dbb6798
YQ
59
60 do_test_unload = "call do_test_unload (%d)" % num
13123da8 61 func = lambda: gdb.execute(do_test_unload)
6dbb6798
YQ
62
63 self.measure.measure(func, num)
64
65 num = num / 2
66 iteration -= 1
67
13123da8 68
6dbb6798
YQ
69class SolibLoadUnload(object):
70 def __init__(self, solib_count):
13123da8 71 self.solib_count = solib_count
6dbb6798
YQ
72
73 def run(self):
74 SolibLoadUnload1(self.solib_count, True).run()
75 SolibLoadUnload1(self.solib_count, False).run()
This page took 0.95288 seconds and 4 git commands to generate.