lua-users home
lua-l archive

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


Hi!

The Lua manual says:
  os.clock()
  Returns an approximation of the amount
  in seconds of CPU time used by the program.

But it appears that on Windows the C function clock()
returns wall-time instead of CPU-time:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/clock?view=vs-2019

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.

Found here:
https://stackoverflow.com/questions/56995690/confused-over-precision-of-luas-os-clock/56995937#comment100526058_56995937