Re: which is faster?

new topic     » goto parent     » topic index » view thread      » older message » newer message

You may use this simple speed comparer:

include sort.e
include machine.e
include misc.e
include get.e
include graphics.e

atom start,finish
integer cycles,x,y
sequence s,t,a

s = "Äà"
t = "Íåò"

cycles = 10000000

puts(1,"Start...\n")

start = time()

function won_lost1(sequence a,sequence b)
      if equal(a,b)  then
         return "Won"
      end if
  return "Lost"
end function

-------------------------or-----------------------

function won_lost2(sequence a,sequence b)
      if equal(a,b)  then
         return "Won"
      else
         return "Lost"
      end if
end function

for i=1 to cycles do
	--construction1
	a = won_lost1(s,t)
end for

finish = time() - start

position(23,2)
printf(1,"time1 = %f sec\n ",finish)

start = time()

for i=1 to cycles do
	--construction2
	a = won_lost2(s,t)
end for

finish = time() - start

printf(1,"time2 = %f sec\n",finish)

x = wait_key()

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu