When I run this:
let t1 = cpuTime()
# some single threaded code
echo("time = ", cpuTime()-t1
I get the correct time (in secs), but when the code is executing in parallel the result is greater than real (clock) time.
What do you use to return the true clock time (stop watch) difference?
Yes, that did it.
This is a good use case example to distinguish in time docs between the use of cpuTime() and epochTime(). The given example for cpuTime() assumes single threaded use and not the effect of multi processor/threads use.
The Unix time command
https://en.wikipedia.org/wiki/Time_%28Unix%29
https://www.lifewire.com/command-return-time-command-4054237
returns three (3) variants: real, usr, sys. Nim's cpuTime() corresponds to usr (total cpu time), whereas epochTime() corresponds to real (clock time).
I would like to recommend that realTime() be included in Nim's time module to make it shadow that component of the Unix time command, which will make it's function and use case much clearer to users. This may only need to create realTime() as an alias of epochTime().
I've made an issue request for this on the Nim Cookbook project :-)
@jzakiya; open a feature request ticket against the nim github repo?