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