1. append speed

is append() function slow?
is repeat() function much faster?

is this:

for i=1 to 100 do
    s=append(s,0)
end for

much slower than this:

s=repeat(100,0)

and how much slower is it?

Anybody has any special set of functions for benchmarking, measuring the
speed of functions?

new topic     » topic index » view message » categorize

2. Re: append speed

>is append() function slow?
>is repeat() function much faster?

atom t,t0, total
sequence s, u

total = 1000000

s = {}

t0 = time()
for i=1 to total do
    s=append(s,"Hand-crafted from only the finest ASCII.\n")
end for
t = time()-t0
printf(1,"Time: %3.2f\n",{t})

u = {}
u=repeat("Microwave hint: Make hole in turtle's shell first.\n",total)
t=time()-t0
printf(1,"Time: %3.2f\n",{t})

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

3. Re: append speed

To benchmark a function:

Take a time reading, run the routine a lot of times, say 100,000 times, and
take another time reading.
Subtract the first from the second.

Now change the routine, and run again, then compare the differences.

Pete King.


-----Original Message-----
From: ©koda <tone.skoda at SIOL.NET>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Friday, May 19, 2000 7:29 PM
Subject: append speed


>is append() function slow?
>is repeat() function much faster?
>
>is this:
>
>for i=1 to 100 do
>    s=append(s,0)
>end for
>
>much slower than this:
>
>s=repeat(100,0)
>
>and how much slower is it?
>
>Anybody has any special set of functions for benchmarking, measuring the
>speed of functions?
>

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

4. Re: append speed

Nice, helpful response R.W.D.; however, I think your code needs to reset t0
right after u = {}, & probably should use exactly the same data in each
sequence, too?  Looks like repeat is about 10 times faster than append to
fill a sequence.

Dan Moyer


-----Original Message-----
From: R. W. D. <filexfer3 at JUNO.COM>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Friday, May 19, 2000 4:36 PM
Subject: Re: append speed


>>is append() function slow?
>>is repeat() function much faster?
>
>atom t,t0, total
>sequence s, u
>
>total = 1000000
>
>s = {}
>
>t0 = time()
>for i=1 to total do
>    s=append(s,"Hand-crafted from only the finest ASCII.\n")
>end for
>t = time()-t0
>printf(1,"Time: %3.2f\n",{t})
>
>u = {}
>u=repeat("Microwave hint: Make hole in turtle's shell first.\n",total)
>t=time()-t0
>printf(1,"Time: %3.2f\n",{t})

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

Search



Quick Links

User menu

Not signed in.

Misc Menu