Difference between revisions of "Os.clock"
From ComputerCraft Wiki
Line 5: | Line 5: | ||
|api=os | |api=os | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc=Returns the amount of time the | + | |desc=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. |
|examples= | |examples= | ||
{{Example | {{Example | ||
|desc=Measure how long a custom function takes to execute | |desc=Measure how long a custom function takes to execute | ||
− | |code=x = os.clock() -- compensates for time already passed<br /> | + | |code=x = os.clock() -- compensates for time already passed<br />mFunction() -- function to be tested<br />y = os.clock()-x -- calculates time change<br />print(y) |
|output=Time it took to run myFunction() | |output=Time it took to run myFunction() | ||
}} | }} | ||
}} | }} |
Revision as of 18:05, 23 September 2012
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