def benchmark_tracer_trace():
tracer = Tracer()
tracer.writer = DummyWriter()
# testcase
def trace(tracer):
# explicit vars
with tracer.trace("a", service="s", resource="r", span_type="t") as s:
s.set_tag("a", "b")
s.set_tag("b", 1)
with tracer.trace("another.thing"):
pass
with tracer.trace("another.thing"):
pass
# benchmark
print("## tracer.trace() benchmark: {} loops ##".format(NUMBER))
timer = timeit.Timer(lambda: trace(tracer))
result = timer.repeat(repeat=REPEAT, number=NUMBER)
print("- trace execution time: {:8.6f}".format(min(result)))
评论列表
文章目录