1########################################################################## 2# Copyright (c) 2009, ETH Zurich. 3# All rights reserved. 4# 5# This file is distributed under the terms in the attached LICENSE file. 6# If you do not find this file, copies can be found by writing to: 7# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8########################################################################## 9 10import re 11import debug, tests, barrelfish 12from common import TestCommon 13from results import RawResults 14 15class TscTestCommon(TestCommon): 16 17 def get_module_name(self): 18 raise NotImplementedError 19 20 def get_modules(self, build, machine): 21 modules = super(TscTestCommon, self).get_modules(build, machine) 22 modules.add_kernel_args(["ticks=false"]) 23 modules.add_module(self.get_module_name()) 24 return modules 25 26 def run(self, build, machine, testdir): 27 modules = self.get_modules(build, machine) 28 self.boot(machine, modules) 29 return self.collect_data(machine) 30 31 def process_data(self, testdir, raw_iter): 32 results = RawResults('Index') 33 34 diff = [] 35 for line in raw_iter: 36 m = re.match("Iteration\s+(\d+): time0 (\d+) time1 (\d+) difference (\d+)", 37 line) 38 if m: 39 diff.append(int(m.group(3)) - int(m.group(2))) 40 41 results.add_group('Index', diff) 42 return results 43 44@tests.add_test 45class TscTest(TscTestCommon): 46 ''' Test to measure the cost of reading from the timestamp counter ''' 47 name = "tsc_test" 48 49 def get_module_name(self): 50 return "tsc_bench" 51 52@tests.add_test 53class ShmcTest(TscTestCommon): 54 ''' Measure cost of shared memory clock ''' 55 name = "shmc_test" 56 57 def get_module_name(self): 58 return "shared_mem_clock_bench" 59 60 def process_data(self, testdir, rawiter): 61 results = RawResults('core') 62 times = [] 63 core = None 64 for line in rawiter: 65 m = re.match("Running on (\d+) cores", line) 66 if m: 67 if times: 68 results.add_group(core, times) 69 core = int(m.group(1)) 70 times = [] 71 continue 72 73 m = re.match("page \d+ took (\d+)", line) 74 if m: 75 assert(core is not None) 76 times.append(int(m.group(1))) 77 78 if len(times) != 0: 79 results.add_group(core, times) 80 return results 81