def meth2(self): time.sleep(0.01) for x in range(5): # used as a context manager with PerfTool('internal'): time.sleep(0.01) for x in range(2): with PerfTool('internal2'): time.sleep(0.01)
def main(): @perf_tool('body') def scoped(): sleep(0.05) with PerfTool('call'): scoped() for row in range(10): with PerfTool('row'): sleep(0.001)
def main(): """ Dummy example of use """ with PerfTool('preparation'): time.sleep(0.01) with PerfTool('calculus'): time.sleep(0.03) with PerfTool('output'): time.sleep(0.02) for row in range(100): with PerfTool('row write'): time.sleep(0.001)
def on_run_off(): # Singleton instance assert PerfTool.set_enabled() yield assert PerfTool.show_stats_if_enabled(return_if_succeeded=True) assert not PerfTool.set_enabled(False) assert PerfTool.show_stats_if_enabled(return_if_succeeded=True) PerfTool.empty() assert not PerfTool.t0 assert not PerfTool.times assert not PerfTool.running
def test_algo1(on_run_off): aa = Case1() for x in range(3): aa.meth1() aa.meth2() for x in range(5): # as a context manager with PerfTool('meth2'): time.sleep(0.01) assert PerfTool.has('meth2') assert PerfTool.has('meth1') assert PerfTool.has('nested') assert PerfTool.has('nested.internal') assert PerfTool.has('nested.internal.internal2')
def __init__(self, instance): PerfTool.__init__(self, instance, 'wrk2')
def __init__(self, instance): PerfTool.__init__(self, 'nuttcp-7.3.2', instance)
def __init__(self, instance, cfg_http_tool): PerfTool.__init__(self, instance, cfg_http_tool)
def __init__(self, instance): PerfTool.__init__(self, 'iperf', instance)
def __init__(self, instance): PerfTool.__init__(self, instance, 'fio')
def __init__(self, instance, perf_tool_path): PerfTool.__init__(self, 'iperf', perf_tool_path, instance)
#!/usr/bin/env python from time import sleep from perf_tool import PerfTool, perf_tool @perf_tool('main') def main(): @perf_tool('body') def scoped(): sleep(0.05) with PerfTool('call'): scoped() for row in range(10): with PerfTool('row'): sleep(0.001) PerfTool.set_enabled() main() PerfTool.show_stats_if_enabled()
def __init__(self, instance): PerfTool.__init__(self, 'iperf-2.0.9', instance)
def __init__(self, instance): PerfTool.__init__(self, 'nuttcp-8.1.4', instance)
def __init__(self, instance): PerfTool.__init__(self, instance, 'nuttcp') self.keys = ['thoroughput', 'time', 'rate', 'tx_cpu', 'jitter', 'latency']
def __init__(self, instance, perf_tool_path): PerfTool.__init__(self, 'nuttcp-7.3.2', perf_tool_path, instance)