blob: 02f34138bd7c2b3cd2c3117bd98302ca2274a352 [file] [log] [blame]
mbligh548ace82006-10-19 14:36:45 +00001#!/usr/bin/python
mbligha440f4a2008-09-09 21:30:04 +00002import os, re
mbligh53da18e2009-01-05 21:13:26 +00003from autotest_lib.client.bin import test, utils
mbligh548ace82006-10-19 14:36:45 +00004
mbligh548ace82006-10-19 14:36:45 +00005
6class iozone(test.test):
mbligha440f4a2008-09-09 21:30:04 +00007 version = 2
mbligh548ace82006-10-19 14:36:45 +00008
mblighc5ddfd12008-08-04 17:15:00 +00009 def initialize(self):
10 self.job.require_gcc()
11
12
jadmanski0afbb632008-06-06 21:10:57 +000013 # http://www.iozone.org/src/current/iozone3_283.tar
mbligha440f4a2008-09-09 21:30:04 +000014 def setup(self, tarball='iozone3_283.tar'):
mbligh8b352852008-06-07 01:07:08 +000015 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
mbligh53da18e2009-01-05 21:13:26 +000016 utils.extract_tarball_to_dir(tarball, self.srcdir)
jadmanski0afbb632008-06-06 21:10:57 +000017 os.chdir(os.path.join(self.srcdir, 'src/current'))
mbligh548ace82006-10-19 14:36:45 +000018
mbligh53da18e2009-01-05 21:13:26 +000019 arch = utils.get_current_kernel_arch()
jadmanski0afbb632008-06-06 21:10:57 +000020 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')
mbligh548ace82006-10-19 14:36:45 +000028
mbligh1f337612007-09-30 01:19:47 +000029
mbligha440f4a2008-09-09 21:30:04 +000030 def run_once(self, dir=None, args=None):
jadmanski0afbb632008-06-06 21:10:57 +000031 if not dir:
32 dir = self.tmpdir
33 os.chdir(dir)
34 if not args:
35 args = '-a'
mbligha440f4a2008-09-09 21:30:04 +000036
mbligh9b21efc2008-10-22 21:47:14 +000037 cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone')
mbligh34b297b2009-02-03 17:49:48 +000038 self.results = utils.system_output('%s %s' % (cmd, args))
39 self.auto_mode = ("-a" in args)
mbligh6303ed62007-07-19 16:19:16 +000040
41
mbligh8110e112009-01-13 21:42:09 +000042 def __get_section_name(self, desc):
mbligha440f4a2008-09-09 21:30:04 +000043 return desc.strip().replace(' ', '_')
44
45
mbligh34b297b2009-02-03 17:49:48 +000046 def postprocess_iteration(self):
mbligha440f4a2008-09-09 21:30:04 +000047 keylist = {}
48
mbligh34b297b2009-02-03 17:49:48 +000049 if self.auto_mode:
mbligha440f4a2008-09-09 21:30:04 +000050 labels = ('write', 'rewrite', 'read', 'reread', 'randread',
51 'randwrite', 'bkwdread', 'recordrewrite',
52 'strideread', 'fwrite', 'frewrite', 'fread', 'freread')
mbligh34b297b2009-02-03 17:49:48 +000053 for line in self.results.splitlines():
mbligha440f4a2008-09-09 21:30:04 +000054 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]+'
mblighc9bde782009-02-06 22:44:31 +000066 '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec')
mbligha440f4a2008-09-09 21:30:04 +000067 parent_regexp = re.compile('Parent sees throughput for[\s]+'
mblighc9bde782009-02-06 22:44:31 +000068 '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec')
mbligha440f4a2008-09-09 21:30:04 +000069
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
mbligh34b297b2009-02-03 17:49:48 +000076 for line in self.results.splitlines():
mbligha440f4a2008-09-09 21:30:04 +000077 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)