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