mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 1 | import os |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 2 | from autotest_lib.client.bin import test, utils |
mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 3 | |
| 4 | |
| 5 | class hackbench(test.test): |
lmr | 6578379 | 2010-04-14 23:58:23 +0000 | [diff] [blame] | 6 | """ |
| 7 | This module will run the hackbench benchmark. Hackbench is a benchmark for |
| 8 | measuring the performance, overhead and scalability of the Linux scheduler. |
| 9 | The C program was pick from Ingo Molnar's page. |
| 10 | |
| 11 | @author: Nikhil Rao (ncrao@google.com) |
| 12 | @see: http://people.redhat.com/~mingo/cfs-scheduler/tools/hackbench.c |
| 13 | """ |
mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 14 | version = 1 |
| 15 | preserve_srcdir = True |
| 16 | |
| 17 | |
| 18 | def setup(self): |
| 19 | os.chdir(self.srcdir) |
| 20 | utils.system('cc -lpthread hackbench.c -o hackbench') |
| 21 | |
| 22 | |
| 23 | def initialize(self): |
| 24 | self.job.require_gcc() |
lmr | 6578379 | 2010-04-14 23:58:23 +0000 | [diff] [blame] | 25 | self.results = None |
mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 26 | |
| 27 | |
| 28 | def run_once(self, num_groups=90): |
lmr | 6578379 | 2010-04-14 23:58:23 +0000 | [diff] [blame] | 29 | """ |
| 30 | Run hackbench, store the output in raw output files per iteration and |
| 31 | also in the results list attribute. |
| 32 | |
| 33 | @param num_groups: Number of children processes hackbench will spawn. |
| 34 | """ |
mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 35 | hackbench_bin = os.path.join(self.srcdir, 'hackbench') |
| 36 | cmd = '%s %s' % (hackbench_bin, num_groups) |
lmr | 6578379 | 2010-04-14 23:58:23 +0000 | [diff] [blame] | 37 | raw_output = utils.system_output(cmd, retain_output=True) |
| 38 | self.results = raw_output |
| 39 | |
| 40 | path = os.path.join(self.resultsdir, 'raw_output_%s' % self.iteration) |
| 41 | raw_output_file = open(path, 'w') |
| 42 | raw_output_file.write(raw_output) |
| 43 | raw_output_file.close() |
mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 44 | |
| 45 | |
lmr | 6578379 | 2010-04-14 23:58:23 +0000 | [diff] [blame] | 46 | def postprocess_iteration(self): |
| 47 | """ |
| 48 | Pick up the results attribute and write it in the performance keyval. |
| 49 | """ |
| 50 | lines = self.results.split('\n') |
| 51 | for line in lines: |
mbligh | 51fca2c | 2008-10-10 21:08:59 +0000 | [diff] [blame] | 52 | if line.startswith('Time:'): |
| 53 | time_val = line.split()[1] |
| 54 | self.write_perf_keyval({'time': time_val}) |