Skip to content

Commit d2f1ae1

Browse files
committed
fix(debugger): reduce code origin startup time
Start with a benchmark to measure opportunities for improvements refs: DEBUG-4605
1 parent 3576477 commit d2f1ae1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

riotfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ def select_pys(min_version: str = MIN_PYTHON_VERSION, max_version: str = MAX_PYT
663663
"httpretty": latest,
664664
"typing-extensions": latest,
665665
"pytest-asyncio": latest,
666+
"pytest-benchmark": latest,
666667
},
667668
pys=select_pys(),
668669
),

tests/debugging/origin/test_span.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from functools import partial
22
from pathlib import Path
3+
import time
34
import typing as t
45

56
import pytest
@@ -169,3 +170,25 @@ def entry_call():
169170
assert _exit.get_tag("_dd.code_origin.type") is None
170171
assert _exit.get_tag("_dd.code_origin.frames.0.file") is None
171172
assert _exit.get_tag("_dd.code_origin.frames.0.line") is None
173+
174+
175+
def test_instrument_view_benchmark(benchmark):
176+
"""Benchmark instrument_view performance when wrapping functions."""
177+
MockSpanCodeOriginProcessorEntry.enable()
178+
179+
try:
180+
181+
def setup():
182+
"""Create a unique function to wrap for each iteration."""
183+
func = eval("lambda: None")
184+
return (func,), {}
185+
186+
# Benchmark the wrapping operation
187+
benchmark.pedantic(
188+
MockSpanCodeOriginProcessorEntry.instrument_view,
189+
setup=setup,
190+
rounds=100,
191+
)
192+
193+
finally:
194+
MockSpanCodeOriginProcessorEntry.disable()

0 commit comments

Comments
 (0)