1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/usr/bin/python
import os
from autotest_lib.client.bin import test, autotest_utils
from autotest_lib.client.common_lib import utils
class iozone(test.test):
version = 1
# http://www.iozone.org/src/current/iozone3_283.tar
def setup(self, tarball = 'iozone3_283.tar'):
tarball = utils.unmap_url(self.bindir, tarball,
self.tmpdir)
autotest_utils.extract_tarball_to_dir(tarball, self.srcdir)
os.chdir(os.path.join(self.srcdir, 'src/current'))
arch = autotest_utils.get_current_kernel_arch()
if (arch == 'ppc'):
utils.system('make linux-powerpc')
elif (arch == 'ppc64'):
utils.system('make linux-powerpc64')
elif (arch == 'x86_64'):
utils.system('make linux-AMD64')
else:
utils.system('make linux')
def execute(self, dir = None, iterations=1, args = None):
self.keyval = open(os.path.join(self.resultsdir, 'keyval'),
'w')
if not dir:
dir = self.tmpdir
os.chdir(dir)
if not args:
args = '-a'
profilers = self.job.profilers
if not profilers.only():
for i in range(iterations):
output = utils.system_output('%s/src/current/iozone %s' %
(self.srcdir, args))
self.__format_results(output)
# Do a profiling run if necessary
if profilers.present():
profilers.start(self)
output = utils.system_output('%s/src/current/iozone %s' %
(self.srcdir, args))
self.__format_results(output)
profilers.stop(self)
profilers.report(self)
self.keyval.close()
def __format_results(self, results):
labels = ('write', 'rewrite', 'read', 'reread', 'randread',
'randwrite', 'bkwdread', 'recordrewrite',
'strideread', 'fwrite', 'frewrite',
'fread', 'freread')
for line in results.splitlines():
fields = line.split()
if len(fields) != 15:
continue
try:
fields = tuple([int(i) for i in fields])
except ValueError:
continue
for l, v in zip(labels, fields[2:]):
print >> self.keyval, "%d-%d-%s=%d" % (fields[0], fields[1], l, v)
print >> self.keyval
|