mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 1 | import os |
| 2 | from autotest_lib.client.bin import test, autotest_utils |
| 3 | from autotest_lib.client.common_lib import utils |
| 4 | |
| 5 | |
| 6 | class hackbench(test.test): |
| 7 | version = 1 |
| 8 | preserve_srcdir = True |
| 9 | |
| 10 | |
| 11 | def setup(self): |
| 12 | os.chdir(self.srcdir) |
| 13 | utils.system('cc -lpthread hackbench.c -o hackbench') |
| 14 | |
| 15 | |
| 16 | def initialize(self): |
| 17 | self.job.require_gcc() |
| 18 | self.results = [] |
| 19 | |
| 20 | |
| 21 | def run_once(self, num_groups=90): |
| 22 | hackbench_bin = os.path.join(self.srcdir, 'hackbench') |
| 23 | cmd = '%s %s' % (hackbench_bin, num_groups) |
| 24 | self.results.append(utils.system_output(cmd, retain_output=True)) |
| 25 | |
| 26 | |
| 27 | def postprocess(self): |
| 28 | for line in self.results: |
| 29 | if line.startswith('Time:'): |
| 30 | time_val = line.split()[1] |
| 31 | self.write_perf_keyval({'time': time_val}) |