Skip to content

Commit 347d84d

Browse files
committed
Also disable other profiler.
1 parent 6868792 commit 347d84d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/pytest_benchmark/fixture.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,18 @@ def _raw(self, function_to_benchmark, *args, **kwargs):
210210
else:
211211
cprofile_loops = range(self.cprofile_loops)
212212
if self.enabled and self.cprofile:
213-
tracer = sys.gettrace()
213+
prev_tracer = sys.gettrace()
214+
prev_profiler = sys.getprofile()
214215
sys.settrace(None)
216+
sys.setprofile(None)
215217
try:
216218
profile = cProfile.Profile()
217219
for _ in cprofile_loops:
218220
function_result = profile.runcall(function_to_benchmark, *args, **kwargs)
219221
self._save_cprofile(profile)
220222
finally:
221-
sys.settrace(tracer)
223+
sys.settrace(prev_tracer)
224+
sys.setprofile(prev_profiler)
222225
else:
223226
function_result = function_to_benchmark(*args, **kwargs)
224227
return function_result

0 commit comments

Comments
 (0)