1# Copyright (C) 2013-2021 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 16from perftest import perftest 17 18 19class 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 37 line_size = 2 38 for _ in range(1, 12): 39 # Keep the total size of dcache unchanged, and increase the 40 # line-size in the loop. 41 line_size_command = "set dcache line-size %d" % (line_size) 42 size_command = "set dcache size %d" % (4096 * 64 / line_size) 43 # Cache is cleared by changing line-size or size. 44 gdb.execute(line_size_command) 45 gdb.execute(size_command) 46 47 func = lambda: self._do_test() 48 49 self.measure.measure(func, line_size) 50 51 line_size *= 2 52