1*9c5db199SXin Liimport os, re 2*9c5db199SXin Lifrom autotest_lib.client.bin import test, utils 3*9c5db199SXin Lifrom autotest_lib.client.common_lib import error 4*9c5db199SXin Li 5*9c5db199SXin Li 6*9c5db199SXin Liclass unixbench(test.test): 7*9c5db199SXin Li version = 2 8*9c5db199SXin Li 9*9c5db199SXin Li def initialize(self): 10*9c5db199SXin Li self.job.require_gcc() 11*9c5db199SXin Li self.err = None 12*9c5db199SXin Li 13*9c5db199SXin Li 14*9c5db199SXin Li # http://www.tux.org/pub/tux/niemi/unixbench/unixbench-4.1.0.tgz 15*9c5db199SXin Li def setup(self, tarball = 'unixbench-4.1.0.tar.bz2'): 16*9c5db199SXin Li tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) 17*9c5db199SXin Li utils.extract_tarball_to_dir(tarball, self.srcdir) 18*9c5db199SXin Li os.chdir(self.srcdir) 19*9c5db199SXin Li 20*9c5db199SXin Li utils.system('patch -p1 < ../unixbench.patch') 21*9c5db199SXin Li utils.system('patch -p1 < ../Makefile.patch') 22*9c5db199SXin Li utils.make() 23*9c5db199SXin Li utils.system('rm pgms/select') 24*9c5db199SXin Li 25*9c5db199SXin Li 26*9c5db199SXin Li def run_once(self, args='', stepsecs=0): 27*9c5db199SXin Li vars = ('TMPDIR=\"%s\" RESULTDIR=\"%s\" FLAVOR=Linux' % 28*9c5db199SXin Li (self.tmpdir, self.resultsdir)) 29*9c5db199SXin Li if stepsecs: 30*9c5db199SXin Li # change time per subtest from unixbench's defaults of 31*9c5db199SXin Li # 10 secs for small tests, 30 secs for bigger tests 32*9c5db199SXin Li vars += ' systime=%i looper=%i seconds=%i'\ 33*9c5db199SXin Li ' dhrytime=%i arithtime=%i' \ 34*9c5db199SXin Li % ((stepsecs,)*5) 35*9c5db199SXin Li 36*9c5db199SXin Li os.chdir(self.srcdir) 37*9c5db199SXin Li try: 38*9c5db199SXin Li utils.system(vars + ' ./Run ' + args) 39*9c5db199SXin Li finally: 40*9c5db199SXin Li times_path = os.path.join(self.resultsdir, 'times') 41*9c5db199SXin Li # The 'times' file can be needlessly huge as it contains warnings 42*9c5db199SXin Li # and error messages printed out by small benchmarks that are 43*9c5db199SXin Li # run in a loop. It can easily compress 100x in such cases. 44*9c5db199SXin Li if os.path.exists(times_path): 45*9c5db199SXin Li utils.system("gzip -9 '%s'" % (times_path,), ignore_status=True) 46*9c5db199SXin Li 47*9c5db199SXin Li report_path = os.path.join(self.resultsdir, 'report') 48*9c5db199SXin Li self.report_data = open(report_path).readlines()[9:] 49*9c5db199SXin Li 50*9c5db199SXin Li 51*9c5db199SXin Li def cleanup(self): 52*9c5db199SXin Li # check err string and possible throw 53*9c5db199SXin Li if self.err is not None: 54*9c5db199SXin Li raise error.TestError(self.err) 55*9c5db199SXin Li 56*9c5db199SXin Li 57*9c5db199SXin Li def check_for_error(self, words): 58*9c5db199SXin Li l = len(words) 59*9c5db199SXin Li if l >= 3 and words[-3:l] == ['no', 'measured', 'results']: 60*9c5db199SXin Li # found a problem so record it in err string 61*9c5db199SXin Li key = '_'.join(words[:-3]) 62*9c5db199SXin Li if self.err is None: 63*9c5db199SXin Li self.err = key 64*9c5db199SXin Li else: 65*9c5db199SXin Li self.err = self.err + " " + key 66*9c5db199SXin Li return True 67*9c5db199SXin Li else: 68*9c5db199SXin Li return False 69*9c5db199SXin Li 70*9c5db199SXin Li 71*9c5db199SXin Li def postprocess_iteration(self): 72*9c5db199SXin Li keyval = {} 73*9c5db199SXin Li for line in self.report_data: 74*9c5db199SXin Li if not line.strip(): 75*9c5db199SXin Li break 76*9c5db199SXin Li 77*9c5db199SXin Li words = line.split() 78*9c5db199SXin Li # look for problems first 79*9c5db199SXin Li if self.check_for_error(words): 80*9c5db199SXin Li continue 81*9c5db199SXin Li 82*9c5db199SXin Li # we should make sure that there are at least 83*9c5db199SXin Li # 6 guys before we start accessing the array 84*9c5db199SXin Li if len(words) >= 6: 85*9c5db199SXin Li key = '_'.join(words[:-6]) 86*9c5db199SXin Li key = re.sub('\W', '', key) 87*9c5db199SXin Li value = words[-6] 88*9c5db199SXin Li keyval[key] = value 89*9c5db199SXin Li for line in self.report_data: 90*9c5db199SXin Li if 'FINAL SCORE' in line: 91*9c5db199SXin Li keyval['score'] = line.split()[-1] 92*9c5db199SXin Li break 93*9c5db199SXin Li self.write_perf_keyval(keyval) 94*9c5db199SXin Li 95*9c5db199SXin Li 96*9c5db199SXin Li""" Here is a sample report file: 97*9c5db199SXin Li 98*9c5db199SXin Li BYTE UNIX Benchmarks (Version 4.1.0) 99*9c5db199SXin Li System -- Linux adrianbg 2.6.18.5 #1 SMP Thu J Start Benchmark Run: Tue Sep 1 100*9c5db199SXin Li 9 interactive users. 101*9c5db199SXin Li 21:03:50 up 5 days, 7:38, 9 users, load average: 0.71, 0.40, 0.25 102*9c5db199SXin Li lrwxrwxrwx 1 root root 4 Aug 15 09:53 /bin/sh -> bash 103*9c5db199SXin Li /bin/sh: symbolic link to `bash' 104*9c5db199SXin Li /dev/sda6 192149596 91964372 90424536 51% /home 105*9c5db199SXin LiDhrystone 2 using register variables 7918001.7 lps (10.0 secs, 10 samples) 106*9c5db199SXin LiSystem Call Overhead 1427272.7 lps (10.0 secs, 10 samples) 107*9c5db199SXin LiProcess Creation 11508.6 lps (30.0 secs, 3 samples) 108*9c5db199SXin LiExecl Throughput 4159.7 lps (29.7 secs, 3 samples) 109*9c5db199SXin LiFile Read 1024 bufsize 2000 maxblocks 1708109.0 KBps (30.0 secs, 3 samples) 110*9c5db199SXin LiFile Write 1024 bufsize 2000 maxblocks 788024.0 KBps (30.0 secs, 3 samples) 111*9c5db199SXin LiFile Copy 1024 bufsize 2000 maxblocks 452986.0 KBps (30.0 secs, 3 samples) 112*9c5db199SXin LiFile Read 256 bufsize 500 maxblocks 508752.0 KBps (30.0 secs, 3 samples) 113*9c5db199SXin LiFile Write 256 bufsize 500 maxblocks 214772.0 KBps (30.0 secs, 3 samples) 114*9c5db199SXin LiFile Copy 256 bufsize 500 maxblocks 143989.0 KBps (30.0 secs, 3 samples) 115*9c5db199SXin LiFile Read 4096 bufsize 8000 maxblocks 2626923.0 KBps (30.0 secs, 3 samples) 116*9c5db199SXin LiFile Write 4096 bufsize 8000 maxblocks 1175070.0 KBps (30.0 secs, 3 samples) 117*9c5db199SXin LiFile Copy 4096 bufsize 8000 maxblocks 793041.0 KBps (30.0 secs, 3 samples) 118*9c5db199SXin LiShell Scripts (1 concurrent) 4417.4 lpm (60.0 secs, 3 samples) 119*9c5db199SXin LiShell Scripts (8 concurrent) 1109.0 lpm (60.0 secs, 3 samples) 120*9c5db199SXin LiShell Scripts (16 concurrent) 578.3 lpm (60.0 secs, 3 samples) 121*9c5db199SXin LiArithmetic Test (type = short) 1843690.0 lps (10.0 secs, 3 samples) 122*9c5db199SXin LiArithmetic Test (type = int) 1873615.8 lps (10.0 secs, 3 samples) 123*9c5db199SXin LiArithmetic Test (type = long) 1888345.9 lps (10.0 secs, 3 samples) 124*9c5db199SXin LiArithmetic Test (type = float) 616260.3 lps (10.0 secs, 3 samples) 125*9c5db199SXin LiArithmetic Test (type = double) 615942.1 lps (10.0 secs, 3 samples) 126*9c5db199SXin LiArithoh 18864899.5 lps (10.0 secs, 3 samples) 127*9c5db199SXin LiDc: sqrt(2) to 99 decimal places 161726.0 lpm (30.0 secs, 3 samples) 128*9c5db199SXin LiRecursion Test--Tower of Hanoi 89229.3 lps (20.0 secs, 3 samples) 129*9c5db199SXin Li 130*9c5db199SXin Li 131*9c5db199SXin Li INDEX VALUES 132*9c5db199SXin LiTEST BASELINE RESULT INDEX 133*9c5db199SXin Li 134*9c5db199SXin LiDhrystone 2 using register variables 116700.0 7918001.7 678.5 135*9c5db199SXin LiDouble-Precision Whetstone 55.0 1948.2 354.2 136*9c5db199SXin LiExecl Throughput 43.0 4159.7 967.4 137*9c5db199SXin LiFile Copy 1024 bufsize 2000 maxblocks 3960.0 452986.0 1143.9 138*9c5db199SXin LiFile Copy 256 bufsize 500 maxblocks 1655.0 143989.0 870.0 139*9c5db199SXin LiFile Copy 4096 bufsize 8000 maxblocks 5800.0 793041.0 1367.3 140*9c5db199SXin LiPipe Throughput 12440.0 1048491.9 842.8 141*9c5db199SXin LiPipe-based Context Switching 4000.0 300778.3 751.9 142*9c5db199SXin LiProcess Creation 126.0 11508.6 913.4 143*9c5db199SXin LiShell Scripts (8 concurrent) 6.0 1109.0 1848.3 144*9c5db199SXin LiSystem Call Overhead 15000.0 1427272.7 951.5 145*9c5db199SXin Li ========= 146*9c5db199SXin Li FINAL SCORE 902.1 147*9c5db199SXin Li""" 148