lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 07-Nov-19 17:36, Egor Skriptunoff wrote:
But it appears that on Windows the C function clock()
returns wall-time instead of CPU-time:

As a result, in Lua on Windows, the function
os.clock() returns wall-clock time.
I've tested it on Lua built with both compilers
(Visual Studio and MinGW-w64).

It looks like it's Microsoft's fault
to incorrectly implement C run-time function.
But Lua should workaround this bug.
Or the Lua manual should be corrected.

I would not venture on the time measuring minefield, of which I unfortunately have some experience on Windows and Linux (if you need precision and monotonicity it gets much worse, not counting OS version compatibility). It would be best to go for the second option, i.e. to simply state that Lua returns time as measured by the underlying C system library call.