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