1. timing tests

Hi everybody,
Try the following test for a bit of an eye opener. Especially the last two divis
ion
results are quite startling! I keep a printout handy. Jiri

-- snip ------------------------------------------------------------------------

include machine.e       -- tick_rate()

object x
sequence s
atom t,dt,dt0
integer j

tick_rate(100)

function abs(atom x)
   if x<0 then x=-x end if
   return x
end function

puts(1,"1,000,000 loop test\n")

t=time()
for i=1 to 1000000 do
   -- empty for loop
end for
dt0=time()-t
printf(1,"empty for loops:                   %5.2f\n",dt0)

t=time()
j=0
while j<1000000 do
   j=j+1
end while
dt=time()-t
printf(1,"empty while loops:                 %5.2f\n",dt)

t=time()
for i=1 to 1000000 do
   x=3
end for
dt=time()-t
printf(1,"assignment:     x=3                %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=3.5
end for
dt=time()-t
printf(1,"assignment:     x=3.5              %5.2f\n",dt-dt0)

s={1,2,3}
t=time()
for i=1 to 1000000 do
   x=s[2]
end for
dt=time()-t
printf(1,"assignment:     x=s[2]             %5.2f\n",dt-dt0)

s={{1,2,3},{1,2,3},{1,2,3}}
t=time()
for i=1 to 1000000 do
   x=s[2][2]
end for
dt=time()-t
printf(1,"assignment:     x=s[2][2]          %5.2f\n",dt-dt0)

s={1,2,3}
t=time()
for i=1 to 1000000 do
   s[2]=3
end for
dt=time()-t
printf(1,"assignment:     s[2]=3             %5.2f\n",dt-dt0)

s={{1,2,3},{1,2,3},{1,2,3}}
t=time()
for i=1 to 1000000 do
   s[2][2]=3
end for
dt=time()-t
printf(1,"assignment:     s[2][2]=3          %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=2+2
end for
dt=time()-t
printf(1,"addition:       x=2+2              %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=1.5+1.5
end for
dt=time()-t
printf(1,"addition:       x=1.5+1.5          %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=5*2
end for
dt=time()-t
printf(1,"multiplication: x=5*2              %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=5*3
end for
dt=time()-t
printf(1,"multiplication: x=5*3              %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=2.5*1.5
end for
dt=time()-t
printf(1,"multiplication: x=2.5*1.5          %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=256/2
end for
dt=time()-t
printf(1,"division:       x=256/2            %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=256/4
end for
dt=time()-t
printf(1,"division:       x=256/4            %5.2f\n",dt-dt0)

for i=1 to 1000000 do
   x=5/2
end for
dt=time()-t
printf(1,"division:       x=5/2              %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=5/3
end for
dt=time()-t
printf(1,"division:       x=5/3              %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=2.5/1.5
end for
dt=time()-t
printf(1,"division:       x=2.5/1.5          %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=floor(3.5)
end for
dt=time()-t
printf(1,"floor:          x=floor(3.5)       %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=remainder(5,3)
end for
dt=time()-t
printf(1,"remainder:      x=remainder(5,3)   %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=remainder(5.5,3)
end for
dt=time()-t
printf(1,"remainder:      x=remainder(5.5,3) %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=abs(-5)
end for
dt=time()-t
printf(1,"abs:            x=abs(-5)          %5.2f\n",dt-dt0)

t=time()
for i=1 to 1000000 do
   x=abs(-5.5)
end for
dt=time()-t
printf(1,"abs:            x=abs(-5.5)        %5.2f\n",dt-dt0)

new topic     » topic index » view message » categorize

2. Re: timing tests

> Hi everybody,
> Try the following test for a bit of an eye opener. Especially the last two div
is
> ion
> results are quite startling! I keep a printout handy. Jiri

        Yes, some things were very supprising..
        I added a few tests.. they also show some very weird results..
        For example, calling a function, that's a huge slowdown.. so only
have functions for large pieces of code, that you have to call at a
lot of different places in you code.
  And this:

        puts(1,"Euphoria rules!!")

  Is a LOT slower than:

        sequence s
        s = "Euphoria rules!!"
        puts(1,s)

 Also the type of object you want to assign a value to determines
speed. Assigning to an object is faster than to a atom if the value
is integer.... (?? That's weird..)

The function sabs included... is the same as abs.. but handles all
kinds of objects... integers, atoms, sequences until any depth.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
~~~~>> Ralf Nieuwenhuijsen <<~~~~
 ~~~>> nieuwen at xs4all.nl <<~~~~

new topic     » goto parent     » topic index » view message » categorize

3. Re: timing tests

--Message-Boundary-10752
Content-type: text/plain; charset=US-ASCII
Content-description: Mail message body


        Oops, like always i forgot to attach the file.. here it is..
        I am really sorry, i don't want to clutter up the list-serv.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
~~~~>> Ralf Nieuwenhuijsen <<~~~~
 ~~~>> nieuwen at xs4all.nl <<~~~~

--Message-Boundary-10752
Content-type: text/plain; charset=US-ASCII
Content-disposition: inline
Content-description: Attachment information.

The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  TESTS.EX
     Date:  7 Aug 1997, 15:48
     Size:  6077 bytes.
     Type:  Text

--Message-Boundary-10752
Content-type: Application/Octet-stream; name=TESTS.EX; type=Text

new topic     » goto parent     » topic index » view message » categorize

4. Re: timing tests

At 14:54 07-08-97 +1200, Jiri wrote:

>Hi everybody,
>Try the following test for a bit of an eye opener. Especially the last two
divis
>ion
>results are quite startling! I keep a printout handy. Jiri
>

Talking about timing test try this one.

-------------------  code begin here ---------------------------------------
atom t,dt0, dt1


constant format = "%03x %03x %03x "

t = time()
for i = 1 to 10000  do
        printf(1,format,{23,46,25})
end for
dt0 = time() - t
clear_screen()
t = time()
for i = 1 to 10000  do
        puts(1,sprintf(format,{23,46,25}))
end for
dt1 = time() - t
printf(1,"using printf() %5.2f\n",{dt0})
printf(1,"using puts(1,sprintf()) %5.2f\n",{dt1})

--------------   code end ------------------------------------------------

On my computer it's more than 2.4 times faster to use puts(1,sprintf())


Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at globetrotter.qc.ca

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu