blob: 4fbec26a62d8519cb3baa26b1892407f3d2f2254 [file] [log] [blame]
mbligha440f4a2008-09-09 21:30:04 +00001import os, re
mbligh53da18e2009-01-05 21:13:26 +00002from autotest_lib.client.bin import test, utils
lmr9aacf2b2010-05-04 13:56:05 +00003import postprocessing
mbligh548ace82006-10-19 14:36:45 +00004
mbligh548ace82006-10-19 14:36:45 +00005
6class iozone(test.test):
lmr7f52bc92010-04-15 01:27:41 +00007 """
8 This autotest module runs the IOzone filesystem benchmark. The benchmark
9 generates and measures a variety of file operations. Iozone has been ported
10 to many machines and runs under many operating systems.
11
12 Iozone is useful for performing a broad filesystem analysis of a vendor's
13 computer platform. The benchmark tests file I/O performance for the
14 following operations:
15
16 Read, write, re-read, re-write, read backwards, read strided, fread, fwrite,
17 random read, pread ,mmap, aio_read, aio_write
18
19 @author: Ying Tao (yingtao@cn.ibm.com)
20 @see: http://www.iozone.org
21 """
22 version = 3
mbligh548ace82006-10-19 14:36:45 +000023
mblighc5ddfd12008-08-04 17:15:00 +000024 def initialize(self):
25 self.job.require_gcc()
26
27
lmr7f52bc92010-04-15 01:27:41 +000028 def setup(self, tarball='iozone3_347.tar'):
29 """
30 Builds the given version of IOzone from a tarball.
31 @param tarball: Tarball with IOzone
32 @see: http://www.iozone.org/src/current/iozone3_347.tar
33 """
mbligh8b352852008-06-07 01:07:08 +000034 tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
mbligh53da18e2009-01-05 21:13:26 +000035 utils.extract_tarball_to_dir(tarball, self.srcdir)
jadmanski0afbb632008-06-06 21:10:57 +000036 os.chdir(os.path.join(self.srcdir, 'src/current'))
mbligh548ace82006-10-19 14:36:45 +000037
mbligh53da18e2009-01-05 21:13:26 +000038 arch = utils.get_current_kernel_arch()
jadmanski0afbb632008-06-06 21:10:57 +000039 if (arch == 'ppc'):
Eric Li6f27d4f2010-09-29 10:55:17 -070040 utils.make('linux-powerpc')
jadmanski0afbb632008-06-06 21:10:57 +000041 elif (arch == 'ppc64'):
Eric Li6f27d4f2010-09-29 10:55:17 -070042 utils.make('linux-powerpc64')
jadmanski0afbb632008-06-06 21:10:57 +000043 elif (arch == 'x86_64'):
Eric Li6f27d4f2010-09-29 10:55:17 -070044 utils.make('linux-AMD64')
jadmanski0afbb632008-06-06 21:10:57 +000045 else:
Eric Li6f27d4f2010-09-29 10:55:17 -070046 utils.make('linux')
mbligh548ace82006-10-19 14:36:45 +000047
mbligh1f337612007-09-30 01:19:47 +000048
mbligha440f4a2008-09-09 21:30:04 +000049 def run_once(self, dir=None, args=None):
lmr7f52bc92010-04-15 01:27:41 +000050 """
51 Runs IOzone with appropriate parameters, record raw results in a per
52 iteration raw output file as well as in the results attribute
53
54 @param dir: IOzone file generation dir.
55 @param args: Arguments to the iozone program.
56 """
jadmanski0afbb632008-06-06 21:10:57 +000057 if not dir:
58 dir = self.tmpdir
59 os.chdir(dir)
60 if not args:
61 args = '-a'
mbligha440f4a2008-09-09 21:30:04 +000062
mbligh9b21efc2008-10-22 21:47:14 +000063 cmd = os.path.join(self.srcdir, 'src', 'current', 'iozone')
mbligh34b297b2009-02-03 17:49:48 +000064 self.results = utils.system_output('%s %s' % (cmd, args))
65 self.auto_mode = ("-a" in args)
mbligh6303ed62007-07-19 16:19:16 +000066
lmr9aacf2b2010-05-04 13:56:05 +000067 self.results_path = os.path.join(self.resultsdir,
68 'raw_output_%s' % self.iteration)
69 self.analysisdir = os.path.join(self.resultsdir,
70 'analysis_%s' % self.iteration)
71
72 utils.open_write_close(self.results_path, self.results)
lmr7f52bc92010-04-15 01:27:41 +000073
mbligh6303ed62007-07-19 16:19:16 +000074
mbligh8110e112009-01-13 21:42:09 +000075 def __get_section_name(self, desc):
mbligha440f4a2008-09-09 21:30:04 +000076 return desc.strip().replace(' ', '_')
77
78
lmr9aacf2b2010-05-04 13:56:05 +000079 def generate_keyval(self):
mbligha440f4a2008-09-09 21:30:04 +000080 keylist = {}
81
mbligh34b297b2009-02-03 17:49:48 +000082 if self.auto_mode:
mbligha440f4a2008-09-09 21:30:04 +000083 labels = ('write', 'rewrite', 'read', 'reread', 'randread',
84 'randwrite', 'bkwdread', 'recordrewrite',
85 'strideread', 'fwrite', 'frewrite', 'fread', 'freread')
mbligh34b297b2009-02-03 17:49:48 +000086 for line in self.results.splitlines():
mbligha440f4a2008-09-09 21:30:04 +000087 fields = line.split()
88 if len(fields) != 15:
89 continue
90 try:
91 fields = tuple([int(i) for i in fields])
92 except ValueError:
93 continue
94 for l, v in zip(labels, fields[2:]):
95 key_name = "%d-%d-%s" % (fields[0], fields[1], l)
96 keylist[key_name] = v
97 else:
98 child_regexp = re.compile('Children see throughput for[\s]+'
mblighc9bde782009-02-06 22:44:31 +000099 '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec')
mbligha440f4a2008-09-09 21:30:04 +0000100 parent_regexp = re.compile('Parent sees throughput for[\s]+'
mblighc9bde782009-02-06 22:44:31 +0000101 '([\d]+)\s+([-\w]+[-\w\s]*)\=[\s]+([\d\.]*) KB/sec')
mbligha440f4a2008-09-09 21:30:04 +0000102
103 KBsec_regexp = re.compile('\=[\s]+([\d\.]*) KB/sec')
104 KBval_regexp = re.compile('\=[\s]+([\d\.]*) KB')
105
106 section = None
107 w_count = 0
108
mbligh34b297b2009-02-03 17:49:48 +0000109 for line in self.results.splitlines():
mbligha440f4a2008-09-09 21:30:04 +0000110 line = line.strip()
111
112 # Check for the beginning of a new result section
113 match = child_regexp.search(line)
114 if match:
115 # Extract the section name and the worker count
116 w_count = int(match.group(1))
117 section = self.__get_section_name(match.group(2))
118
119 # Output the appropriate keyval pair
120 key_name = '%s-%d-kids' % (section, w_count)
121 keylist[key_name] = match.group(3)
122 continue
123
124 # Check for any other interesting lines
125 if '=' in line:
126 # Is it something we recognize? First check for parent.
127 match = parent_regexp.search(line)
128 if match:
129 # The section name and the worker count better match
130 p_count = int(match.group(1))
131 p_secnt = self.__get_section_name(match.group(2))
132 if p_secnt != section or p_count != w_count:
133 continue
134
135 # Set the base name for the keyval
136 basekey = 'parent'
137 else:
138 # Check for the various 'throughput' values
139 if line[3:26] == ' throughput per thread ':
140 basekey = line[0:3]
141 match_x = KBsec_regexp
142 else:
143 # The only other thing we expect is 'Min xfer'
144 if not line.startswith('Min xfer '):
145 continue
146 basekey = 'MinXfer'
147 match_x = KBval_regexp
148
149 match = match_x.search(line)
150 if match:
151 result = match.group(1)
152 key_name = "%s-%d-%s" % (section, w_count, basekey)
153 keylist[key_name] = result
154
155 self.write_perf_keyval(keylist)
lmr9aacf2b2010-05-04 13:56:05 +0000156
157
158 def postprocess_iteration(self):
159 self.generate_keyval()
160 if self.auto_mode:
161 a = postprocessing.IOzoneAnalyzer(list_files=[self.results_path],
162 output_dir=self.analysisdir)
163 a.analyze()
164 p = postprocessing.IOzonePlotter(results_file=self.results_path,
165 output_dir=self.analysisdir)
166 p.plot_all()