Difference between revisions of "Os.clock"

From ComputerCraft Wiki
Jump to: navigation, search
(Undo revision 3168 by 91.121.27.33 (talk))
m (Moved to CAT:LuaCoreFunctions)
Line 13: Line 13:
 
}}
 
}}
 
}}
 
}}
 +
 +
[[Category:Lua_Core_Functions]]

Revision as of 18:49, 28 November 2012


Grid Redstone.png  Function os.clock
Returns the amount of time the Computer has been running, note that this may not be the amount of time the program has been running. the function os.clock() is useful for debugging, see the example.
Syntax os.clock()
Returns float, amount of time the computercraft computer has been running, in seconds.
Part of ComputerCraft
API os

Examples

Grid paper.png  Example
Measure how long a custom function takes to execute
Code
x = os.clock() -- compensates for time already passed
mFunction() -- function to be tested
y = os.clock()-x -- calculates time change
print(y)
Output Time it took to run myFunction()