os.clock

Amount of elapsed/CPU time used (depending on OS)

Prototype

cpu = os.clock ()

Description

Returns the approximate amount of CPU time used by the current process in seconds.

print (os.clock () / 60 / 60) --> 34.381006944444 (hours)
WARNING - under Linux and Mac OS os.clock returns the CPU time used. However, under Windows it returns the elapsed time that the process has been running (not the CPU time used). This is because the operating system call "clock" works differently under Windows.

Lua functions

Topics