Skip to content

Commit

Permalink
doc times: do not use now (and also epochTime) for benchmarking (n…
Browse files Browse the repository at this point in the history
…im-lang#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>
  • Loading branch information
2 people authored and ardek66 committed Mar 26, 2021
1 parent 8f357f9 commit a3146b3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pure/times.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a3146b3

Please sign in to comment.