mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 2 | import os, re |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 3 | from autotest_lib.client.bin import test, utils |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 4 | |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 5 | |
| 6 | class iozone(test.test): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 7 | version = 2 |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 8 | |
mbligh | c5ddfd1 | 2008-08-04 17:15:00 +0000 | [diff] [blame] | 9 | def initialize(self): |
| 10 | self.job.require_gcc() |
| 11 | |
| 12 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 13 | # http://www.iozone.org/src/current/iozone3_283.tar |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 14 | def setup(self, tarball='iozone3_283.tar'): |
mbligh | 8b35285 | 2008-06-07 01:07:08 +0000 | [diff] [blame] | 15 | tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 16 | utils.extract_tarball_to_dir(tarball, self.srcdir) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 17 | os.chdir(os.path.join(self.srcdir, 'src/current')) |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 18 | |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 19 | arch = utils.get_current_kernel_arch() |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 20 | if (arch == 'ppc'): |
| 21 | utils.system('make linux-powerpc') |
| 22 | elif (arch == 'ppc64'): |
| 23 | utils.system('make linux-powerpc64') |
| 24 | elif (arch == 'x86_64'): |
| 25 | utils.system('make linux-AMD64') |
| 26 | else: |
| 27 | utils.system('make linux') |
mbligh | 548ace8 | 2006-10-19 14:36:45 +0000 | [diff] [blame] | 28 | |
mbligh | 1f33761 | 2007-09-30 01:19:47 +0000 | [diff] [blame] | 29 | |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 30 | def run_once(self, dir=None, args=None): |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 31 | if not dir: |
| 32 | dir = self.tmpdir |
| 33 | os.chdir(dir) |
| 34 | if not args: |
| 35 | args = '-a' |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 36 | |
mbligh | 9b21efc | 2008-10-22 21:47:14 +0000 | [diff] [blame] | 37 | cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone') |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 38 | self.results = utils.system_output('%s %s' % (cmd, args)) |
| 39 | self.auto_mode = ("-a" in args) |
mbligh | 6303ed6 | 2007-07-19 16:19:16 +0000 | [diff] [blame] | 40 | |
| 41 | |
mbligh | 8110e11 | 2009-01-13 21:42:09 +0000 | [diff] [blame] | 42 | def __get_section_name(self, desc): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 43 | return desc.strip().replace(' ', '_') |
| 44 | |
| 45 | |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 46 | def postprocess_iteration(self): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 47 | keylist = {} |
| 48 | |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 49 | if self.auto_mode: |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 50 | labels = ('write', 'rewrite', 'read', 'reread', 'randread', |
| 51 | 'randwrite', 'bkwdread', 'recordrewrite', |
| 52 | 'strideread', 'fwrite', 'frewrite', 'fread', 'freread') |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 53 | for line in self.results.splitlines(): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 54 | fields = line.split() |
| 55 | if len(fields) != 15: |
| 56 | continue |
| 57 | try: |
| 58 | fields = tuple([int(i) for i in fields]) |
| 59 | except ValueError: |
| 60 | continue |
| 61 | for l, v in zip(labels, fields[2:]): |
| 62 | key_name = "%d-%d-%s" % (fields[0], fields[1], l) |
| 63 | keylist[key_name] = v |
| 64 | else: |
| 65 | child_regexp = re.compile('Children see throughput for[\s]+' |
| 66 | '([\d]+)\s+([\w]+[\w\s]*)\=[\s]+([\d\.]*) KB/sec') |
| 67 | parent_regexp = re.compile('Parent sees throughput for[\s]+' |
| 68 | '([\d]+)\s+([\w]+[\w\s]*)\=[\s]+([\d\.]*) KB/sec') |
| 69 | |
| 70 | KBsec_regexp = re.compile('\=[\s]+([\d\.]*) KB/sec') |
| 71 | KBval_regexp = re.compile('\=[\s]+([\d\.]*) KB') |
| 72 | |
| 73 | section = None |
| 74 | w_count = 0 |
| 75 | |
mbligh | 34b297b | 2009-02-03 17:49:48 +0000 | [diff] [blame] | 76 | for line in self.results.splitlines(): |
mbligh | a440f4a | 2008-09-09 21:30:04 +0000 | [diff] [blame] | 77 | line = line.strip() |
| 78 | |
| 79 | # Check for the beginning of a new result section |
| 80 | match = child_regexp.search(line) |
| 81 | if match: |
| 82 | # Extract the section name and the worker count |
| 83 | w_count = int(match.group(1)) |
| 84 | section = self.__get_section_name(match.group(2)) |
| 85 | |
| 86 | # Output the appropriate keyval pair |
| 87 | key_name = '%s-%d-kids' % (section, w_count) |
| 88 | keylist[key_name] = match.group(3) |
| 89 | continue |
| 90 | |
| 91 | # Check for any other interesting lines |
| 92 | if '=' in line: |
| 93 | # Is it something we recognize? First check for parent. |
| 94 | match = parent_regexp.search(line) |
| 95 | if match: |
| 96 | # The section name and the worker count better match |
| 97 | p_count = int(match.group(1)) |
| 98 | p_secnt = self.__get_section_name(match.group(2)) |
| 99 | if p_secnt != section or p_count != w_count: |
| 100 | continue |
| 101 | |
| 102 | # Set the base name for the keyval |
| 103 | basekey = 'parent' |
| 104 | else: |
| 105 | # Check for the various 'throughput' values |
| 106 | if line[3:26] == ' throughput per thread ': |
| 107 | basekey = line[0:3] |
| 108 | match_x = KBsec_regexp |
| 109 | else: |
| 110 | # The only other thing we expect is 'Min xfer' |
| 111 | if not line.startswith('Min xfer '): |
| 112 | continue |
| 113 | basekey = 'MinXfer' |
| 114 | match_x = KBval_regexp |
| 115 | |
| 116 | match = match_x.search(line) |
| 117 | if match: |
| 118 | result = match.group(1) |
| 119 | key_name = "%s-%d-%s" % (section, w_count, basekey) |
| 120 | keylist[key_name] = result |
| 121 | |
| 122 | self.write_perf_keyval(keylist) |
| 123 | |