475 posts
Posted 29 October 2012 - 03:02 AM
Hi everyone! :P/>/>
I'm trying to make something find out how long a program took to run. Does anybody know how to do this?
8543 posts
Posted 29 October 2012 - 03:04 AM
Make a wrapper program. Check os.clock() before you start the other program, check os.clock() after you run it. Simple subtraction gives you the run time.
2217 posts
Location
3232235883
Posted 29 October 2012 - 03:58 AM
local otime=os.clock()
-- code
local timeElapsed=os.clock()-otime
2088 posts
Location
South Africa
Posted 29 October 2012 - 06:26 PM
Wow loops are fast xD
term.clear() term.setCursorPos(1,1)
BeginTime = os.time()
i = 1
repeat
i = i + 1
until i == 1000000
print(os.time() - BeginTime)
Results 0.001 :P/>/>
2005 posts
Posted 29 October 2012 - 08:30 PM
They're faster than that. It's the world time that's too slow. Use the os.clock, like Lyqyd said. It's more suited to this purpose.