blob: 15e93d7b18173642683e0f436b536b7a31c662ae [file] [log] [blame]
import os
from autotest_lib.client.bin import test, utils
class hackbench(test.test):
This module will run the hackbench benchmark. Hackbench is a benchmark for
measuring the performance, overhead and scalability of the Linux scheduler.
The C program was pick from Ingo Molnar's page.
@author: Nikhil Rao (
version = 1
preserve_srcdir = True
def setup(self):
if 'CC' in os.environ:
cc = '$CC'
cc = 'cc'
utils.system('%s -lpthread hackbench.c -o hackbench' % cc)
def initialize(self):
self.results = None
def run_once(self, num_groups=90):
Run hackbench, store the output in raw output files per iteration and
also in the results list attribute.
@param num_groups: Number of children processes hackbench will spawn.
hackbench_bin = os.path.join(self.srcdir, 'hackbench')
cmd = '%s %s' % (hackbench_bin, num_groups)
raw_output = utils.system_output(cmd, retain_output=True)
self.results = raw_output
path = os.path.join(self.resultsdir, 'raw_output_%s' % self.iteration)
utils.open_write_close(path, raw_output)
def postprocess_iteration(self):
Pick up the results attribute and write it in the performance keyval.
lines = self.results.split('\n')
for line in lines:
if line.startswith('Time:'):
time_val = line.split()[1]
self.write_perf_keyval({'time': time_val})