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