Skip to content

Commit 7e7fe0c

Browse files
authored
Merge pull request #4573 from Liam-DeVoe/timing
Better timing tracking
2 parents 4a3cbdc + 1f63dfb commit 7e7fe0c

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RELEASE_TYPE: patch
2+
3+
Improve the accuracy of test timing reports, by tracking the start time of each test case closer to when the test is executed.

hypothesis-python/src/hypothesis/core.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -997,24 +997,24 @@ def test(*args, **kwargs):
997997
arg_drawtime = math.fsum(data.draw_times.values())
998998
arg_stateful = math.fsum(data._stateful_run_times.values())
999999
arg_gctime = gc_cumulative_time()
1000-
start = time.perf_counter()
1001-
try:
1002-
with unwrap_markers_from_group(), ensure_free_stackframes():
1000+
with unwrap_markers_from_group(), ensure_free_stackframes():
1001+
start = time.perf_counter()
1002+
try:
10031003
result = self.test(*args, **kwargs)
1004-
finally:
1005-
finish = time.perf_counter()
1006-
in_drawtime = math.fsum(data.draw_times.values()) - arg_drawtime
1007-
in_stateful = (
1008-
math.fsum(data._stateful_run_times.values()) - arg_stateful
1009-
)
1010-
in_gctime = gc_cumulative_time() - arg_gctime
1011-
runtime = finish - start - in_drawtime - in_stateful - in_gctime
1012-
self._timing_features = {
1013-
"execute:test": runtime,
1014-
"overall:gc": in_gctime,
1015-
**data.draw_times,
1016-
**data._stateful_run_times,
1017-
}
1004+
finally:
1005+
finish = time.perf_counter()
1006+
in_drawtime = math.fsum(data.draw_times.values()) - arg_drawtime
1007+
in_stateful = (
1008+
math.fsum(data._stateful_run_times.values()) - arg_stateful
1009+
)
1010+
in_gctime = gc_cumulative_time() - arg_gctime
1011+
runtime = finish - start - in_drawtime - in_stateful - in_gctime
1012+
self._timing_features = {
1013+
"execute:test": runtime,
1014+
"overall:gc": in_gctime,
1015+
**data.draw_times,
1016+
**data._stateful_run_times,
1017+
}
10181018

10191019
if (
10201020
(current_deadline := self.settings.deadline) is not None

0 commit comments

Comments
 (0)