Os.clock: Difference between revisions
From GiderosMobile
No edit summary |
No edit summary |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
''' | '''Available since:''' Gideros 2011.6<br/> | ||
''' | '''Class:''' [[os]]<br/> | ||
=== | |||
=== Description === | |||
< | Returns CPU time used by the program in seconds. | ||
<syntaxhighlight lang="lua"> | |||
(number) = os.clock() | (number) = os.clock() | ||
</ | </syntaxhighlight> | ||
=== | |||
''' | === Return values === | ||
'''Returns''' (number) CPU time in seconds<br/> | |||
=== Example === | |||
<syntaxhighlight lang="lua"> | |||
local x = os.clock() | |||
local s = 0 | |||
for i = 1, 10000000 do s = s + i end | |||
print(string.format("elapsed time: %.2f\n", os.clock() - x)) | |||
-- output: elapsed time: 0.39 | |||
</syntaxhighlight> | |||
{{Os}} | |||
Latest revision as of 19:01, 15 December 2023
Available since: Gideros 2011.6
Class: os
Description
Returns CPU time used by the program in seconds.
(number) = os.clock()
Return values
Returns (number) CPU time in seconds
Example
local x = os.clock()
local s = 0
for i = 1, 10000000 do s = s + i end
print(string.format("elapsed time: %.2f\n", os.clock() - x))
-- output: elapsed time: 0.39