forked from autotest/autotest-client-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracing_microbenchmark.py
51 lines (38 loc) · 1.46 KB
/
tracing_microbenchmark.py
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
import os
import re
from autotest.client import test
from autotest.client import utils
import tracers
import base_tracer
class tracing_microbenchmark(test.test):
version = 1
preserve_srcdir = True
def setup(self):
os.chdir(self.srcdir)
utils.system('make CROSS_COMPILE=""')
def initialize(self, tracer='ftrace', calls=100000, **kwargs):
self.job.require_gcc()
tracer_class = getattr(tracers, tracer)
if not issubclass(tracer_class, base_tracer.Tracer):
raise TypeError
self.tracer = tracer_class()
getuid_microbench = os.path.join(self.srcdir, 'getuid_microbench')
self.cmd = '%s %d' % (getuid_microbench, calls)
def warmup(self, buffer_size_kb=8000, **kwargs):
self.tracer.warmup(buffer_size_kb)
def cleanup(self):
self.tracer.cleanup()
def run_once(self, **kwargs):
self.results = {}
self.tracer.start_tracing()
self.cmd_result = utils.run(self.cmd)
self.tracer.stop_tracing()
self.tracer.gather_stats(self.results)
self.tracer.reset_tracing()
def postprocess_iteration(self):
result_re = re.compile(r'(?P<calls>\d+) calls '
r'in (?P<time>\d+\.\d+) s '
'\((?P<ns_per_call>\d+\.\d+) ns/call\)')
match = result_re.match(self.cmd_result.stdout)
self.results.update(match.groupdict())
self.write_perf_keyval(self.results)