OLD | NEW |
(Empty) | |
| 1 import os |
| 2 import re |
| 3 from autotest_lib.client.bin import test |
| 4 from autotest_lib.client.bin import utils |
| 5 |
| 6 import tracers |
| 7 import base_tracer |
| 8 |
| 9 class tracing_microbenchmark(test.test): |
| 10 version = 1 |
| 11 preserve_srcdir = True |
| 12 |
| 13 def setup(self): |
| 14 os.chdir(self.srcdir) |
| 15 utils.system('make CROSS_COMPILE=""') |
| 16 |
| 17 def initialize(self, tracer='ftrace', calls=100000, **kwargs): |
| 18 self.job.require_gcc() |
| 19 tracer_class = getattr(tracers, tracer) |
| 20 if not issubclass(tracer_class, base_tracer.Tracer): |
| 21 raise TypeError |
| 22 self.tracer = tracer_class() |
| 23 |
| 24 getuid_microbench = os.path.join(self.srcdir, 'getuid_microbench') |
| 25 self.cmd = '%s %d' % (getuid_microbench, calls) |
| 26 |
| 27 def warmup(self, buffer_size_kb=8000, **kwargs): |
| 28 self.tracer.warmup(buffer_size_kb) |
| 29 |
| 30 def cleanup(self): |
| 31 self.tracer.cleanup() |
| 32 |
| 33 def run_once(self, **kwargs): |
| 34 self.results = {} |
| 35 |
| 36 self.tracer.start_tracing() |
| 37 self.cmd_result = utils.run(self.cmd) |
| 38 self.tracer.stop_tracing() |
| 39 |
| 40 self.tracer.gather_stats(self.results) |
| 41 self.tracer.reset_tracing() |
| 42 |
| 43 def postprocess_iteration(self): |
| 44 result_re = re.compile(r'(?P<calls>\d+) calls ' |
| 45 r'in (?P<time>\d+\.\d+) s ' |
| 46 '\((?P<ns_per_call>\d+\.\d+) ns/call\)') |
| 47 match = result_re.match(self.cmd_result.stdout) |
| 48 self.results.update(match.groupdict()) |
| 49 |
| 50 self.write_perf_keyval(self.results) |
OLD | NEW |