1. Speed of global function

Rob, i was playing with creating a reverse function, and consistently found
that mine was 2 to 3 to 5  times slower than the global reverse in misc.e.

however, when i 'copied'  the global reverse function as my own 'test'
function -- only the names were changed to protect the innocent -- it was
still at least twice as slow as the global function. for example:
    10,000 reps, 99 elements,  0.16  vs  0.06  seconds total time in for
loop
    10,000 reps, 999 elements,  1.54  vs  0.71 seconds
    10,000 reps, 99,999 elements, 312.75  versus 252.55 seconds

i find that odd. is there a 'built in' reason for it...?

code on request,


--
jon

jxliv7 at hotmail.com

new topic     » topic index » view message » categorize

2. Re: Speed of global function

jxliv7 at hotmail.com wrote:
> Rob, this doesn't make sense.
> 
> execution time range in seconds with various iterations and elements
> t =  3.02	   30.65      17.03	copy of RDS code
> s =  3.96	   39.44      22.3      Ricardo's code
> r =  2.3	   22.9       12.65 	RDS code
> 							
> Ricardo, the guy who wrote the original Test2 claimed that it
> was sometimes faster than your global routine.
> 
> i am thoroughly confused. can you help me see what's going on...?

So you seem to be saying that the official reverse() in misc.e
is the fastest, but you are concerned that a similar routine
that you coded using different variables is quite a bit slower.
You also found Ricardo Forno's reverse to be slower than
the official one.

I just tried your code on my Pentium-4 machine,
and it showed Forno's routine to be the fastest (by 20%
over the official), your rewritten reverse() to be 2nd fastest and
the official one to be third fastest, although
yours and the official one were very close.

On my Pentium-2 under Linux I got essentially the same
results, but the gap between fastest and slowest was narrow.

A few years ago, on this list, we considered several
different ways of doing reverse(), and I remember
that the top contenders were pretty close, and
sometimes the relative order varied
from one machine to the next. I can't really explain it,
but when you have small loops the modern Pentiums do some
really sophisticated and unpredictable stuff to
speed things up.

Regards,
    Rob Craig
    Rapid Deployment Software
    http://www.RapidEuphoria.com

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

3. Re: Speed of global function

jxliv7 at hotmail.com wrote:
> but it still doesn't explain how i can just change the names on your
> global routine and get completely slower consistent times.
> 
> a routine by any other variables is still that routine, no?

Small loops can be susceptible to Pentium cache conflicts
that depend on exactly where in memory the code and variables
are located. This issue came up a few years ago:

(watch out for wrap)
http://www.listfilter.com/cgi-bin/esearch.exu?fromMonth=4&fromYear=4&toMonth=4&toYear=4&postedBy=rds&keywords=cache

Besides that, I don't know of anything in the way the
interpreter is coded that would make a routine run faster
or slower depending on where it is located in the program.

Regards,
    Rob Craig
    Rapid Deployment Software
    http://www.RapidEuphoria.com

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

4. Re: Speed of global function

On Sat, 16 Aug 2003 22:48:28 +0000, jxliv7 at hotmail.com wrote:

>Rob, appreciate the response.
>but it still doesn't explain how i can just change the names on your
>global routine and get completely slower consistent times.

One thing that might possibly be happening (and trust me, I'm by no
means any kind of expert on this point) is that if you do:

	thousands of runs of a
then
	thousands of runs of b

then part way though b, the garbage collector might decide it is time
to do a little housekeeping that wasn't necessary during the run of a.
The reverse (ooh, bad pun) could also be true, that a incurs some cost
allocating quite a bit of memory, and b just reuses it.
You might get a fairer comparison if you time each case in its own
program, maybe not...

Although I accept you are probably just experimenting for a bit of
fun, it is worth saying that shaving 20% off a routine which is
already quite fast will have almost no effect whatsoever on the
performance of a larger program.

Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu