Skip to content

Commit

Permalink
fix documentation to make more accurate claims
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Aug 27, 2021
1 parent 67be8b9 commit 228717c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@

- Fixed buffer overflow bugs in `net`

- Added `std/cputicks` containing APIs for nanosecond resolution CPU counters, providing strictly monotonic
counters with highest available resolution.
- Added `std/cputicks` containing APIs for CPU counters with highest performance available.

- Exported `sslHandle` from `net` and `asyncnet`.

Expand Down
13 changes: 9 additions & 4 deletions lib/std/cputicks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ else:
proc getCpuTicksImpl(): uint64 {.importc: "__rdtsc", header: header.}

template getCpuTicks*(): int64 =
## Returns number of CPU ticks as given by the `RDTSC` instruction.
## Unlike `std/monotimes.ticks`, this gives a strictly monotonic counter
## and has higher resolution and lower overhead,
## Returns number of CPU ticks as given by a platform specific timestamp counter,
## oftentimes the `RDTSC` instruction.
## Unlike `std/monotimes.ticks`, this gives a strictly monotonic counter at least
## on recent enough x86 platforms, and has higher resolution and lower overhead,
## allowing to measure individual instructions (corresponding to time offsets in
## the nanosecond range).
## the nanosecond range). A best effort implementation is provided when a timestamp
## counter is not available.
##
## Note that the CPU may reorder instructions.
runnableExamples:
Expand All @@ -55,6 +57,9 @@ proc getCpuTicksStart*(): int64 {.inline.} =
## `getCpuTicks`, this avoids introducing noise in the measurements caused by
## CPU instruction reordering, and can result in more deterministic results,
## at the expense of extra overhead and requiring asymetric start/stop APIs.
##
## A best effort implementation is provided for platforms where `RDTSCP` is
## not available.
runnableExamples:
var a = 0
for i in 0..<100:
Expand Down
2 changes: 1 addition & 1 deletion lib/std/monotimes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ that the actual supported time resolution differs for different systems.
See also
========
* `times module <times.html>`_
* `cputicks module <times.html>`_ which provides strictly monotonic cpu counter
* `cputicks module <times.html>`_ which provides cpu counters with highest available performance
]##

import times
Expand Down

0 comments on commit 228717c

Please sign in to comment.