futures profiling instrumentation

This commit is contained in:
Jaremy Creechley 2023-10-26 15:23:13 -07:00
parent f9909c4053
commit ac6c22c51a
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 4 additions and 0 deletions

View File

@ -319,6 +319,9 @@ proc futureContinue*(fut: FutureBase) {.raises: [], gcsafe.} =
var next: FutureBase
template iterate =
while true:
when chronosFuturesInstrumentation:
if not(isNil(onFutureRunning)):
onFutureRunning(fut)
# Call closure to make progress on `fut` until it reaches `yield` (inside
# `await` typically) or completes / fails / is cancelled
next = fut.internalClosure(fut)

View File

@ -247,6 +247,7 @@ suite "Asynchronous utilities test suite":
echo "avg wallTime:\t", v.totalWallTime div count, "\ttotal: ", v.totalWallTime
echo "avg runTime:\t", v.totalRunTime div count, "\ttotal: ", v.totalRunTime
if k.procedure == "simpleAsync1":
echo "v: ", v
check v.totalExecTime >= 150.milliseconds()
check v.totalExecTime <= 180.milliseconds()