blob: f7ae7c6b7c024a458080cc5b18675efa86212b90 [file] [log] [blame]
mblighf074a932009-02-06 22:52:53 +00001import os, re
mbligh53da18e2009-01-05 21:13:26 +00002from autotest_lib.client.bin import test, utils
3from autotest_lib.client.common_lib import error
mbligh9f857922008-06-05 16:19:07 +00004
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.err = None
mblighc5ddfd12008-08-04 17:15:00 +000012
13
jadmanski0afbb632008-06-06 21:10:57 +000014 # http://www.tux.org/pub/tux/niemi/unixbench/unixbench-4.1.0.tgz
15 def setup(self, tarball = 'unixbench-4.1.0.tar.bz2'):
mbligh8b352852008-06-07 01:07:08 +000016 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
mbligh53da18e2009-01-05 21:13:26 +000017 utils.extract_tarball_to_dir(tarball, self.srcdir)
jadmanski0afbb632008-06-06 21:10:57 +000018 os.chdir(self.srcdir)
mblighb71116b2006-05-17 21:32:55 +000019
jadmanski0afbb632008-06-06 21:10:57 +000020 utils.system('patch -p1 < ../unixbench.patch')
mbligh5ba43b22010-01-05 18:18:02 +000021 utils.system('patch -p1 < ../Makefile.patch')
jadmanski0afbb632008-06-06 21:10:57 +000022 utils.system('make')
mbligh8de9a4d2008-03-04 16:12:02 +000023
24
mbligh64ed9742008-09-11 21:59:56 +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
mbligh64ed9742008-09-11 21:59:56 +000038 report_path = os.path.join(self.resultsdir, 'report')
mbligh690cdcb2009-02-06 22:50:40 +000039 self.report_data = open(report_path).readlines()[9:]
mbligh22b3a332008-08-28 21:00:31 +000040
41
42 def cleanup(self):
jadmanski0afbb632008-06-06 21:10:57 +000043 # check err string and possible throw
mblighd876f452008-12-03 15:09:17 +000044 if self.err is not None:
jadmanski0afbb632008-06-06 21:10:57 +000045 raise error.TestError(self.err)
mbligh5e3ad612007-10-12 23:34:37 +000046
47
jadmanski0afbb632008-06-06 21:10:57 +000048 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])
mblighd876f452008-12-03 15:09:17 +000053 if self.err is None:
jadmanski0afbb632008-06-06 21:10:57 +000054 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
jadmanski0afbb632008-06-06 21:10:57 +000061
mbligh34b297b2009-02-03 17:49:48 +000062 def postprocess_iteration(self):
63 keyval = {}
64 for line in self.report_data:
jadmanski0afbb632008-06-06 21:10:57 +000065 if not line.strip():
66 break
67
68 words = line.split()
69 # look for problems first
70 if self.check_for_error(words):
71 continue
72
73 # we should make sure that there are at least
74 # 6 guys before we start accessing the array
75 if len(words) >= 6:
76 key = '_'.join(words[:-6])
mblighf074a932009-02-06 22:52:53 +000077 key = re.sub('\W', '', key)
jadmanski0afbb632008-06-06 21:10:57 +000078 value = words[-6]
mbligh34b297b2009-02-03 17:49:48 +000079 keyval[key] = value
80 for line in self.report_data:
jadmanski0afbb632008-06-06 21:10:57 +000081 if 'FINAL SCORE' in line:
mbligh34b297b2009-02-03 17:49:48 +000082 keyval['score'] = line.split()[-1]
jadmanski0afbb632008-06-06 21:10:57 +000083 break
mbligh34b297b2009-02-03 17:49:48 +000084 self.write_perf_keyval(keyval)
mbligh5e3ad612007-10-12 23:34:37 +000085
86
mbligh5e3ad612007-10-12 23:34:37 +000087""" Here is a sample report file:
88
89 BYTE UNIX Benchmarks (Version 4.1.0)
90 System -- Linux adrianbg 2.6.18.5 #1 SMP Thu J Start Benchmark Run: Tue Sep 1
91 9 interactive users.
92 21:03:50 up 5 days, 7:38, 9 users, load average: 0.71, 0.40, 0.25
93 lrwxrwxrwx 1 root root 4 Aug 15 09:53 /bin/sh -> bash
94 /bin/sh: symbolic link to `bash'
95 /dev/sda6 192149596 91964372 90424536 51% /home
96Dhrystone 2 using register variables 7918001.7 lps (10.0 secs, 10 samples)
97System Call Overhead 1427272.7 lps (10.0 secs, 10 samples)
98Process Creation 11508.6 lps (30.0 secs, 3 samples)
99Execl Throughput 4159.7 lps (29.7 secs, 3 samples)
100File Read 1024 bufsize 2000 maxblocks 1708109.0 KBps (30.0 secs, 3 samples)
101File Write 1024 bufsize 2000 maxblocks 788024.0 KBps (30.0 secs, 3 samples)
102File Copy 1024 bufsize 2000 maxblocks 452986.0 KBps (30.0 secs, 3 samples)
103File Read 256 bufsize 500 maxblocks 508752.0 KBps (30.0 secs, 3 samples)
104File Write 256 bufsize 500 maxblocks 214772.0 KBps (30.0 secs, 3 samples)
105File Copy 256 bufsize 500 maxblocks 143989.0 KBps (30.0 secs, 3 samples)
106File Read 4096 bufsize 8000 maxblocks 2626923.0 KBps (30.0 secs, 3 samples)
107File Write 4096 bufsize 8000 maxblocks 1175070.0 KBps (30.0 secs, 3 samples)
108File Copy 4096 bufsize 8000 maxblocks 793041.0 KBps (30.0 secs, 3 samples)
109Shell Scripts (1 concurrent) 4417.4 lpm (60.0 secs, 3 samples)
110Shell Scripts (8 concurrent) 1109.0 lpm (60.0 secs, 3 samples)
111Shell Scripts (16 concurrent) 578.3 lpm (60.0 secs, 3 samples)
112Arithmetic Test (type = short) 1843690.0 lps (10.0 secs, 3 samples)
113Arithmetic Test (type = int) 1873615.8 lps (10.0 secs, 3 samples)
114Arithmetic Test (type = long) 1888345.9 lps (10.0 secs, 3 samples)
115Arithmetic Test (type = float) 616260.3 lps (10.0 secs, 3 samples)
116Arithmetic Test (type = double) 615942.1 lps (10.0 secs, 3 samples)
117Arithoh 18864899.5 lps (10.0 secs, 3 samples)
118Dc: sqrt(2) to 99 decimal places 161726.0 lpm (30.0 secs, 3 samples)
119Recursion Test--Tower of Hanoi 89229.3 lps (20.0 secs, 3 samples)
120
121
122 INDEX VALUES
123TEST BASELINE RESULT INDEX
124
125Dhrystone 2 using register variables 116700.0 7918001.7 678.5
126Double-Precision Whetstone 55.0 1948.2 354.2
127Execl Throughput 43.0 4159.7 967.4
128File Copy 1024 bufsize 2000 maxblocks 3960.0 452986.0 1143.9
129File Copy 256 bufsize 500 maxblocks 1655.0 143989.0 870.0
130File Copy 4096 bufsize 8000 maxblocks 5800.0 793041.0 1367.3
131Pipe Throughput 12440.0 1048491.9 842.8
132Pipe-based Context Switching 4000.0 300778.3 751.9
133Process Creation 126.0 11508.6 913.4
134Shell Scripts (8 concurrent) 6.0 1109.0 1848.3
135System Call Overhead 15000.0 1427272.7 951.5
136 =========
137 FINAL SCORE 902.1
138"""