def benchmark_tracer_wrap():
tracer = Tracer()
tracer.writer = DummyWriter()
# testcase
class Foo(object):
@staticmethod
@tracer.wrap()
def s():
return 0
@classmethod
@tracer.wrap()
def c(cls):
return 0
@tracer.wrap()
def m(self):
return 0
f = Foo()
# benchmark
print("## tracer.trace() wrapper benchmark: {} loops ##".format(NUMBER))
timer = timeit.Timer(f.s)
result = timer.repeat(repeat=REPEAT, number=NUMBER)
print("- staticmethod execution time: {:8.6f}".format(min(result)))
timer = timeit.Timer(f.c)
result = timer.repeat(repeat=REPEAT, number=NUMBER)
print("- classmethod execution time: {:8.6f}".format(min(result)))
timer = timeit.Timer(f.m)
result = timer.repeat(repeat=REPEAT, number=NUMBER)
print("- method execution time: {:8.6f}".format(min(result)))
评论列表
文章目录