Os.clock

From ComputerCraft Wiki
Revision as of 22:40, 5 May 2012 by Mman2112 (Talk | contribs) (use of os.clock())

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Returns the amount of time the computer craft 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, for example to see how long a custom function takes to execute use the following code:

x = os.clock() -- compensates for time already passed
myfunction() -- function to be tested
y = (os.clock() - x) -- calculates time change
print(y)