blob: 1d1f7b0aaa779c6b86746df374017f1351a22b3d [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')
38 output = utils.system_output('%s %s' % (cmd, args))
mbligha440f4a2008-09-09 21:30:04 +000039
40 auto_mode = ("-a" in args)
41 self.__format_results(output, auto_mode)
mbligh6303ed62007-07-19 16:19:16 +000042
43
mbligh8110e112009-01-13 21:42:09 +000044 def __get_section_name(self, desc):
mbligha440f4a2008-09-09 21:30:04 +000045 return desc.strip().replace(' ', '_')
46
47
48 def __format_results(self, results, auto_mode):
49 keylist = {}
50
51 if auto_mode:
52 labels = ('write', 'rewrite', 'read', 'reread', 'randread',
53 'randwrite', 'bkwdread', 'recordrewrite',
54 'strideread', 'fwrite', 'frewrite', 'fread', 'freread')
55 for line in results.splitlines():
56 fields = line.split()
57 if len(fields) != 15:
58 continue
59 try:
60 fields = tuple([int(i) for i in fields])
61 except ValueError:
62 continue
63 for l, v in zip(labels, fields[2:]):
64 key_name = "%d-%d-%s" % (fields[0], fields[1], l)
65 keylist[key_name] = v
66 else:
67 child_regexp = re.compile('Children see throughput for[\s]+'
68 '([\d]+)\s+([\w]+[\w\s]*)\=[\s]+([\d\.]*) KB/sec')
69 parent_regexp = re.compile('Parent sees throughput for[\s]+'
70 '([\d]+)\s+([\w]+[\w\s]*)\=[\s]+([\d\.]*) KB/sec')
71
72 KBsec_regexp = re.compile('\=[\s]+([\d\.]*) KB/sec')
73 KBval_regexp = re.compile('\=[\s]+([\d\.]*) KB')
74
75 section = None
76 w_count = 0
77
78 for line in results.splitlines():
79 line = line.strip()
80
81 # Check for the beginning of a new result section
82 match = child_regexp.search(line)
83 if match:
84 # Extract the section name and the worker count
85 w_count = int(match.group(1))
86 section = self.__get_section_name(match.group(2))
87
88 # Output the appropriate keyval pair
89 key_name = '%s-%d-kids' % (section, w_count)
90 keylist[key_name] = match.group(3)
91 continue
92
93 # Check for any other interesting lines
94 if '=' in line:
95 # Is it something we recognize? First check for parent.
96 match = parent_regexp.search(line)
97 if match:
98 # The section name and the worker count better match
99 p_count = int(match.group(1))
100 p_secnt = self.__get_section_name(match.group(2))
101 if p_secnt != section or p_count != w_count:
102 continue
103
104 # Set the base name for the keyval
105 basekey = 'parent'
106 else:
107 # Check for the various 'throughput' values
108 if line[3:26] == ' throughput per thread ':
109 basekey = line[0:3]
110 match_x = KBsec_regexp
111 else:
112 # The only other thing we expect is 'Min xfer'
113 if not line.startswith('Min xfer '):
114 continue
115 basekey = 'MinXfer'
116 match_x = KBval_regexp
117
118 match = match_x.search(line)
119 if match:
120 result = match.group(1)
121 key_name = "%s-%d-%s" % (section, w_count, basekey)
122 keylist[key_name] = result
123
124 self.write_perf_keyval(keylist)
125