I'm trying to make something find out how long a program took to run. Does anybody know how to do this?
Find out how long a program took to run?
Started by lieudusty, Oct 29 2012 03:02 AM
4 replies to this topic
#1
Posted 29 October 2012 - 03:02 AM
Hi everyone!
/>
I'm trying to make something find out how long a program took to run. Does anybody know how to do this?
I'm trying to make something find out how long a program took to run. Does anybody know how to do this?
#2
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.
#3
Posted 29 October 2012 - 03:58 AM
local otime=os.clock() -- code local timeElapsed=os.clock()-otime
#4
Posted 29 October 2012 - 06:26 PM
Wow loops are fast xD
Results 0.001
/>
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
#5
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.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











