Jump to content




Find out how long a program took to run?


  • You cannot reply to this topic
4 replies to this topic

#1 lieudusty

  • Members
  • 419 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?

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 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.

#3 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 29 October 2012 - 03:58 AM

local otime=os.clock()
-- code
local timeElapsed=os.clock()-otime


#4 remiX

  • Members
  • 2,076 posts
  • LocationSouth 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/>

#5 ChunLing

  • Members
  • 2,027 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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users