mbligh | 9f85792 | 2008-06-05 16:19:07 +0000 | [diff] [blame] | 1 | import os |
| 2 | from autotest_lib.client.bin import test, autotest_utils |
| 3 | from autotest_lib.client.common_lib import utils, error |
| 4 | |
mbligh | b71116b | 2006-05-17 21:32:55 +0000 | [diff] [blame] | 5 | |
| 6 | class unixbench(test.test): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 7 | version = 2 |
mbligh | b71116b | 2006-05-17 21:32:55 +0000 | [diff] [blame] | 8 | |
mbligh | c5ddfd1 | 2008-08-04 17:15:00 +0000 | [diff] [blame] | 9 | def initialize(self): |
| 10 | self.job.require_gcc() |
mbligh | 64ed974 | 2008-09-11 21:59:56 +0000 | [diff] [blame] | 11 | keyval_path = os.path.join(self.resultsdir, 'keyval') |
| 12 | self.keyval = open(keyval_path, 'w') |
mbligh | 22b3a33 | 2008-08-28 21:00:31 +0000 | [diff] [blame] | 13 | self.err = None |
mbligh | c5ddfd1 | 2008-08-04 17:15:00 +0000 | [diff] [blame] | 14 | |
| 15 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 16 | # http://www.tux.org/pub/tux/niemi/unixbench/unixbench-4.1.0.tgz |
| 17 | def setup(self, tarball = 'unixbench-4.1.0.tar.bz2'): |
mbligh | 8b35285 | 2008-06-07 01:07:08 +0000 | [diff] [blame] | 18 | tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 19 | autotest_utils.extract_tarball_to_dir(tarball, self.srcdir) |
| 20 | os.chdir(self.srcdir) |
mbligh | b71116b | 2006-05-17 21:32:55 +0000 | [diff] [blame] | 21 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 22 | utils.system('patch -p1 < ../unixbench.patch') |
| 23 | utils.system('make') |
mbligh | 8de9a4d | 2008-03-04 16:12:02 +0000 | [diff] [blame] | 24 | |
| 25 | |
mbligh | 64ed974 | 2008-09-11 21:59:56 +0000 | [diff] [blame] | 26 | def run_once(self, args='', stepsecs=0): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 27 | vars = ('TMPDIR=\"%s\" RESULTDIR=\"%s\"' % |
| 28 | (self.tmpdir, self.resultsdir)) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 29 | if stepsecs: |
| 30 | # change time per subtest from unixbench's defaults of |
| 31 | # 10 secs for small tests, 30 secs for bigger tests |
| 32 | vars += ' systime=%i looper=%i seconds=%i'\ |
| 33 | ' dhrytime=%i arithtime=%i' \ |
| 34 | % ((stepsecs,)*5) |
mbligh | 8de9a4d | 2008-03-04 16:12:02 +0000 | [diff] [blame] | 35 | |
mbligh | 22b3a33 | 2008-08-28 21:00:31 +0000 | [diff] [blame] | 36 | os.chdir(self.srcdir) |
| 37 | utils.system(vars + ' ./Run ' + args) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 38 | |
mbligh | 64ed974 | 2008-09-11 21:59:56 +0000 | [diff] [blame] | 39 | report_path = os.path.join(self.resultsdir, 'report') |
jadmanski | 987b747 | 2008-09-11 22:32:34 +0000 | [diff] [blame] | 40 | report = open(report_path) |
mbligh | 22b3a33 | 2008-08-28 21:00:31 +0000 | [diff] [blame] | 41 | self.format_results(report, self.keyval) |
| 42 | |
| 43 | |
| 44 | def cleanup(self): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 45 | # check err string and possible throw |
mbligh | d876f45 | 2008-12-03 15:09:17 +0000 | [diff] [blame^] | 46 | if self.err is not None: |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 47 | raise error.TestError(self.err) |
mbligh | 5e3ad61 | 2007-10-12 23:34:37 +0000 | [diff] [blame] | 48 | |
| 49 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 50 | 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]) |
mbligh | d876f45 | 2008-12-03 15:09:17 +0000 | [diff] [blame^] | 55 | if self.err is None: |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 56 | self.err = key |
| 57 | else: |
| 58 | self.err = self.err + " " + key |
| 59 | return True |
| 60 | else: |
| 61 | return False |
mbligh | 5e3ad61 | 2007-10-12 23:34:37 +0000 | [diff] [blame] | 62 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 63 | |
| 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 |
mbligh | 5e3ad61 | 2007-10-12 23:34:37 +0000 | [diff] [blame] | 86 | |
| 87 | |
mbligh | 5e3ad61 | 2007-10-12 23:34:37 +0000 | [diff] [blame] | 88 | """ Here is a sample report file: |
| 89 | |
| 90 | BYTE UNIX Benchmarks (Version 4.1.0) |
| 91 | System -- Linux adrianbg 2.6.18.5 #1 SMP Thu J Start Benchmark Run: Tue Sep 1 |
| 92 | 9 interactive users. |
| 93 | 21:03:50 up 5 days, 7:38, 9 users, load average: 0.71, 0.40, 0.25 |
| 94 | lrwxrwxrwx 1 root root 4 Aug 15 09:53 /bin/sh -> bash |
| 95 | /bin/sh: symbolic link to `bash' |
| 96 | /dev/sda6 192149596 91964372 90424536 51% /home |
| 97 | Dhrystone 2 using register variables 7918001.7 lps (10.0 secs, 10 samples) |
| 98 | System Call Overhead 1427272.7 lps (10.0 secs, 10 samples) |
| 99 | Process Creation 11508.6 lps (30.0 secs, 3 samples) |
| 100 | Execl Throughput 4159.7 lps (29.7 secs, 3 samples) |
| 101 | File Read 1024 bufsize 2000 maxblocks 1708109.0 KBps (30.0 secs, 3 samples) |
| 102 | File Write 1024 bufsize 2000 maxblocks 788024.0 KBps (30.0 secs, 3 samples) |
| 103 | File Copy 1024 bufsize 2000 maxblocks 452986.0 KBps (30.0 secs, 3 samples) |
| 104 | File Read 256 bufsize 500 maxblocks 508752.0 KBps (30.0 secs, 3 samples) |
| 105 | File Write 256 bufsize 500 maxblocks 214772.0 KBps (30.0 secs, 3 samples) |
| 106 | File Copy 256 bufsize 500 maxblocks 143989.0 KBps (30.0 secs, 3 samples) |
| 107 | File Read 4096 bufsize 8000 maxblocks 2626923.0 KBps (30.0 secs, 3 samples) |
| 108 | File Write 4096 bufsize 8000 maxblocks 1175070.0 KBps (30.0 secs, 3 samples) |
| 109 | File Copy 4096 bufsize 8000 maxblocks 793041.0 KBps (30.0 secs, 3 samples) |
| 110 | Shell Scripts (1 concurrent) 4417.4 lpm (60.0 secs, 3 samples) |
| 111 | Shell Scripts (8 concurrent) 1109.0 lpm (60.0 secs, 3 samples) |
| 112 | Shell Scripts (16 concurrent) 578.3 lpm (60.0 secs, 3 samples) |
| 113 | Arithmetic Test (type = short) 1843690.0 lps (10.0 secs, 3 samples) |
| 114 | Arithmetic Test (type = int) 1873615.8 lps (10.0 secs, 3 samples) |
| 115 | Arithmetic Test (type = long) 1888345.9 lps (10.0 secs, 3 samples) |
| 116 | Arithmetic Test (type = float) 616260.3 lps (10.0 secs, 3 samples) |
| 117 | Arithmetic Test (type = double) 615942.1 lps (10.0 secs, 3 samples) |
| 118 | Arithoh 18864899.5 lps (10.0 secs, 3 samples) |
| 119 | Dc: sqrt(2) to 99 decimal places 161726.0 lpm (30.0 secs, 3 samples) |
| 120 | Recursion Test--Tower of Hanoi 89229.3 lps (20.0 secs, 3 samples) |
| 121 | |
| 122 | |
| 123 | INDEX VALUES |
| 124 | TEST BASELINE RESULT INDEX |
| 125 | |
| 126 | Dhrystone 2 using register variables 116700.0 7918001.7 678.5 |
| 127 | Double-Precision Whetstone 55.0 1948.2 354.2 |
| 128 | Execl Throughput 43.0 4159.7 967.4 |
| 129 | File Copy 1024 bufsize 2000 maxblocks 3960.0 452986.0 1143.9 |
| 130 | File Copy 256 bufsize 500 maxblocks 1655.0 143989.0 870.0 |
| 131 | File Copy 4096 bufsize 8000 maxblocks 5800.0 793041.0 1367.3 |
| 132 | Pipe Throughput 12440.0 1048491.9 842.8 |
| 133 | Pipe-based Context Switching 4000.0 300778.3 751.9 |
| 134 | Process Creation 126.0 11508.6 913.4 |
| 135 | Shell Scripts (8 concurrent) 6.0 1109.0 1848.3 |
| 136 | System Call Overhead 15000.0 1427272.7 951.5 |
| 137 | ========= |
| 138 | FINAL SCORE 902.1 |
| 139 | """ |