]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.perf/backtrace.py
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.perf / backtrace.py
1 # Copyright (C) 2013-2024 Free Software Foundation, Inc.
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 from perftest import perftest
17
18
19 class BackTrace(perftest.TestCaseWithBasicMeasurements):
20 def __init__(self, depth):
21 super(BackTrace, self).__init__("backtrace")
22 self.depth = depth
23
24 def warm_up(self):
25 # Warm up.
26 gdb.execute("bt", False, True)
27 gdb.execute("bt", False, True)
28
29 def _do_test(self):
30 """Do backtrace multiple times."""
31 do_test_command = "bt %d" % self.depth
32 for _ in range(1, 15):
33 gdb.execute(do_test_command, False, True)
34
35 def execute_test(self):
36 line_size = 2
37 for _ in range(1, 12):
38 # Keep the total size of dcache unchanged, and increase the
39 # line-size in the loop.
40 line_size_command = "set dcache line-size %d" % (line_size)
41 size_command = "set dcache size %d" % (4096 * 64 / line_size)
42 # Cache is cleared by changing line-size or size.
43 gdb.execute(line_size_command)
44 gdb.execute(size_command)
45
46 func = lambda: self._do_test()
47
48 self.measure.measure(func, line_size)
49
50 line_size *= 2