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>
This commit is contained in:
Timothee Cour
2021-03-18 07:17:20 -07:00
committed by GitHub
parent 9d4d27a3ce
commit 4dd34feb08

View File

@@ -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)