From 4dd34feb0821bac2689721c320e35b650bfdc387 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 18 Mar 2021 07:17:20 -0700 Subject: [PATCH] doc times: do not use `now` (and also `epochTime`) for benchmarking (#17405) * doc times: do not use now for benchmarking * Update lib/pure/times.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Update lib/pure/times.nim Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> --- lib/pure/times.nim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pure/times.nim b/lib/pure/times.nim index e4d31867ba..e763b17bbd 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -1323,8 +1323,10 @@ proc local*(t: Time): DateTime = proc now*(): DateTime {.tags: [TimeEffect], benign.} = ## Get the current time as a `DateTime` in the local timezone. - ## ## Shorthand for `getTime().local`. + ## + ## .. warning:: Unsuitable for benchmarking, use `monotimes.getMonoTime` or + ## `cpuTime` instead, depending on the use case. getTime().local proc initDateTime*(monthday: MonthdayRange, month: Month, year: int, @@ -2575,6 +2577,9 @@ proc epochTime*(): float {.tags: [TimeEffect].} = ## on the hardware/OS). ## ## `getTime` should generally be preferred over this proc. + ## + ## .. warning:: Unsuitable for benchmarking (but still better than `now`), + ## use `monotimes.getMonoTime` or `cpuTime` instead, depending on the use case. when defined(macosx): var a {.noinit.}: Timeval gettimeofday(a)