blob: d98fd81ee5d3334262046595e1faa484770f69bb [file] [log] [blame]
mbligh9f857922008-06-05 16:19:07 +00001import os
2from autotest_lib.client.bin import test, autotest_utils
3from autotest_lib.client.common_lib import utils, error
4
mblighb71116b2006-05-17 21:32:55 +00005
6class unixbench(test.test):
jadmanski0afbb632008-06-06 21:10:57 +00007 version = 2
mblighb71116b2006-05-17 21:32:55 +00008
mblighc5ddfd12008-08-04 17:15:00 +00009 def initialize(self):
10 self.job.require_gcc()
mbligh22b3a332008-08-28 21:00:31 +000011 self.keyval = open(self.resultsdir + '/keyval', 'w')
12 self.err = None
mblighc5ddfd12008-08-04 17:15:00 +000013
14
jadmanski0afbb632008-06-06 21:10:57 +000015 # http://www.tux.org/pub/tux/niemi/unixbench/unixbench-4.1.0.tgz
16 def setup(self, tarball = 'unixbench-4.1.0.tar.bz2'):
mbligh8b352852008-06-07 01:07:08 +000017 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
jadmanski0afbb632008-06-06 21:10:57 +000018 autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
19 os.chdir(self.srcdir)
mblighb71116b2006-05-17 21:32:55 +000020
jadmanski0afbb632008-06-06 21:10:57 +000021 utils.system('patch -p1 < ../unixbench.patch')
22 utils.system('make')
mbligh8de9a4d2008-03-04 16:12:02 +000023
24
mbligh22b3a332008-08-28 21:00:31 +000025 def run_once(self, args = '', stepsecs=0):
jadmanski0afbb632008-06-06 21:10:57 +000026 vars = ('TMPDIR=\"%s\" RESULTDIR=\"%s\"' %
27 (self.tmpdir, self.resultsdir))
jadmanski0afbb632008-06-06 21:10:57 +000028 if stepsecs:
29 # change time per subtest from unixbench's defaults of
30 # 10 secs for small tests, 30 secs for bigger tests
31 vars += ' systime=%i looper=%i seconds=%i'\
32 ' dhrytime=%i arithtime=%i' \
33 % ((stepsecs,)*5)
mbligh8de9a4d2008-03-04 16:12:02 +000034
mbligh22b3a332008-08-28 21:00:31 +000035 os.chdir(self.srcdir)
36 utils.system(vars + ' ./Run ' + args)
jadmanski0afbb632008-06-06 21:10:57 +000037
mbligh22b3a332008-08-28 21:00:31 +000038 report_path = os.path.join(self.resultsdir + '/report')
39 report = open(report_path, 'a')
40 self.format_results(report, self.keyval)
41
42
43 def cleanup(self):
jadmanski0afbb632008-06-06 21:10:57 +000044 # check err string and possible throw
45 if self.err != None:
46 raise error.TestError(self.err)
mbligh5e3ad612007-10-12 23:34:37 +000047
48
jadmanski0afbb632008-06-06 21:10:57 +000049 def check_for_error(self, words):
50 l = len(words)
51 if l >= 3 and words[-3:l] == ['no', 'measured', 'results']:
52 # found a problem so record it in err string
53 key = '_'.join(words[:-3])
54 if self.err == None:
55 self.err = key
56 else:
57 self.err = self.err + " " + key
58 return True
59 else:
60 return False
mbligh5e3ad612007-10-12 23:34:37 +000061
jadmanski0afbb632008-06-06 21:10:57 +000062
63 def format_results(self, report, keyval):
64 for i in range(9):
65 report.next()
66 for line in report:
67 if not line.strip():
68 break
69
70 words = line.split()
71 # look for problems first
72 if self.check_for_error(words):
73 continue
74
75 # we should make sure that there are at least
76 # 6 guys before we start accessing the array
77 if len(words) >= 6:
78 key = '_'.join(words[:-6])
79 value = words[-6]
80 print >> keyval, '%s=%s' % (key, value)
81 for line in report:
82 if 'FINAL SCORE' in line:
83 print >> keyval, 'score=%s\n' % line.split()[-1]
84 break
mbligh5e3ad612007-10-12 23:34:37 +000085
86
87if __name__ == '__main__':
jadmanski0afbb632008-06-06 21:10:57 +000088 import sys
89 unixbench.format_results(sys.stdin, sys.stdout)
mbligh5e3ad612007-10-12 23:34:37 +000090
91
92""" Here is a sample report file:
93
94 BYTE UNIX Benchmarks (Version 4.1.0)
95 System -- Linux adrianbg 2.6.18.5 #1 SMP Thu J Start Benchmark Run: Tue Sep 1
96 9 interactive users.
97 21:03:50 up 5 days, 7:38, 9 users, load average: 0.71, 0.40, 0.25
98 lrwxrwxrwx 1 root root 4 Aug 15 09:53 /bin/sh -> bash
99 /bin/sh: symbolic link to `bash'
100 /dev/sda6 192149596 91964372 90424536 51% /home
101Dhrystone 2 using register variables 7918001.7 lps (10.0 secs, 10 samples)
102System Call Overhead 1427272.7 lps (10.0 secs, 10 samples)
103Process Creation 11508.6 lps (30.0 secs, 3 samples)
104Execl Throughput 4159.7 lps (29.7 secs, 3 samples)
105File Read 1024 bufsize 2000 maxblocks 1708109.0 KBps (30.0 secs, 3 samples)
106File Write 1024 bufsize 2000 maxblocks 788024.0 KBps (30.0 secs, 3 samples)
107File Copy 1024 bufsize 2000 maxblocks 452986.0 KBps (30.0 secs, 3 samples)
108File Read 256 bufsize 500 maxblocks 508752.0 KBps (30.0 secs, 3 samples)
109File Write 256 bufsize 500 maxblocks 214772.0 KBps (30.0 secs, 3 samples)
110File Copy 256 bufsize 500 maxblocks 143989.0 KBps (30.0 secs, 3 samples)
111File Read 4096 bufsize 8000 maxblocks 2626923.0 KBps (30.0 secs, 3 samples)
112File Write 4096 bufsize 8000 maxblocks 1175070.0 KBps (30.0 secs, 3 samples)
113File Copy 4096 bufsize 8000 maxblocks 793041.0 KBps (30.0 secs, 3 samples)
114Shell Scripts (1 concurrent) 4417.4 lpm (60.0 secs, 3 samples)
115Shell Scripts (8 concurrent) 1109.0 lpm (60.0 secs, 3 samples)
116Shell Scripts (16 concurrent) 578.3 lpm (60.0 secs, 3 samples)
117Arithmetic Test (type = short) 1843690.0 lps (10.0 secs, 3 samples)
118Arithmetic Test (type = int) 1873615.8 lps (10.0 secs, 3 samples)
119Arithmetic Test (type = long) 1888345.9 lps (10.0 secs, 3 samples)
120Arithmetic Test (type = float) 616260.3 lps (10.0 secs, 3 samples)
121Arithmetic Test (type = double) 615942.1 lps (10.0 secs, 3 samples)
122Arithoh 18864899.5 lps (10.0 secs, 3 samples)
123Dc: sqrt(2) to 99 decimal places 161726.0 lpm (30.0 secs, 3 samples)
124Recursion Test--Tower of Hanoi 89229.3 lps (20.0 secs, 3 samples)
125
126
127 INDEX VALUES
128TEST BASELINE RESULT INDEX
129
130Dhrystone 2 using register variables 116700.0 7918001.7 678.5
131Double-Precision Whetstone 55.0 1948.2 354.2
132Execl Throughput 43.0 4159.7 967.4
133File Copy 1024 bufsize 2000 maxblocks 3960.0 452986.0 1143.9
134File Copy 256 bufsize 500 maxblocks 1655.0 143989.0 870.0
135File Copy 4096 bufsize 8000 maxblocks 5800.0 793041.0 1367.3
136Pipe Throughput 12440.0 1048491.9 842.8
137Pipe-based Context Switching 4000.0 300778.3 751.9
138Process Creation 126.0 11508.6 913.4
139Shell Scripts (8 concurrent) 6.0 1109.0 1848.3
140System Call Overhead 15000.0 1427272.7 951.5
141 =========
142 FINAL SCORE 902.1
143"""