1. RE: Speed of global function

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...?


--Test002.ex-----------  
include misc.e					--for global reverse

--integer a, b, c, d
sequence a, b
atom t, s, r

--global function reverse(sequence s)
---- reverse the top-level elements of a sequence.
---- Thanks to Hawke' for helping to make this run faster.
--	integer lower, n, n2
--	sequence t
--	n = length(s)
--	n2 = floor(n/2)+1
--	t = repeat(0, n)
--	lower = 1
--	for upper = n to n2 by -1 do
--	t[upper] = s[lower]
--	t[lower] = s[upper]
--	lower += 1
--	end for
--	return t
--end function

function test1(sequence in)		--my "copy" of global reverse above
sequence out					
integer stop, start, mid
	stop = length(in)
	out = repeat(0, stop)
	mid = floor(stop/2)+1
	start = 1
	for i = stop to mid by -1 do
		out[start] = in[i]
		out[i] = in[start]
		start += 1
	end for
return out
end function

				--from genfunc.e, a set of general usage routines.
				--Version 1.9 - 2003/06/27
				--Author: Ricardo M. Forno				
function Test2(sequence a)	--a different reverse	
sequence b			--that i would think would be FASTER
integer c				
	c = length(a)
	b = repeat(0, c)
	for i = 1 to c do
	b[c] = a[i]
	c -= 1
	end for
	return b
end function

t = time()				--my duplicate of global reverse
for ii = 1 to 5 do 			--adjust iterations
a = repeat(9, 9999999)		--make file to be reversed
b = test1(a)
end for
t = time() - t

s = time()				--Test2
for ii = 1 to 5 do 			--adjust as above
a = repeat(9, 9999999)		--adjust same as file above
b = Test2(a)
end for
s = time() - s

r = time()				--the global reverse routine
for ii = 1 to 5 do 			--adjust as above
a = repeat(9, 9999999)		--adjust same as file above
b = reverse(a)
end for
r = time() - r


--
jon

jxliv7 at hotmail.com

new topic     » topic index » view message » categorize

2. RE: Speed of global function

Rob, appreciate the response.

> Robert Craig wrote:
>
> 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.
> 

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?

i had suspected that Forno's routine would be faster, simply because it 
left out an assignment and a calculation compared to the other two 
routines.

i had not considered that the machine i running it on might make a 
difference.

thanks, 


--
jon

jxliv7 at hotmail.com

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

3. RE: Speed of global function

thanks for the explanation, Rob. very interesting.

at first glance, i might take that as an incentive for programming at 
the machine language level. however, i can see that memory size and 
cache size as well as all the other things that AMD, Intel, Via, 
Transmeta, etc., can do with a stream of commands in an application make 
development a nightmare.

frankly, i would put accuracy ahead of speed, except where it's just 
unbelievably excessive.

thanks,


--
jon

jxliv7 at hotmail.com

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

4. RE: Speed of global function

> Pete Lomax wrote: 
>
>>jxliv7 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're absolutely right, Pete, i had not even considered
swapping the order of running the sections of the program...

although, i just swapped places and got the same crazy results as
before -- strange...

> You might get a fairer comparison if you time each case in its own
> program, maybe not...

again, quite true, i should try that as well. good idea... 

> 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.
> 

actually, it might. the routine i was trying to compact would
run every now and then in the application, reversing a sequence 
with as many as 99,999,999 million elements. why the difference between 
38 seconds and 22 seconds makes me wonder.

anyway, enough of that. i'm moving on...


--
jon

jxliv7 at hotmail.com

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

5. RE: Speed of global function

On 17 Aug 2003 at 1:49, jxliv7 at hotmail.com wrote:

> > 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.
> > 
> 
> actually, it might. the routine i was trying to compact would
> run every now and then in the application, reversing a sequence 
> with as many as 99,999,999 million elements. why the difference between 
> 38 seconds and 22 seconds makes me wonder.
> 
FYI, reversiing a 20 element string with a built-in
function is a full 28 times faster.
A 100 element sequence reverses 38 times faster.

Karl Bochert

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

6. RE: Speed of global function

> FYI, reversiing a 20 element string with a built-in
> function is a full 28 times faster.
> A 100 element sequence reverses 38 times faster.
> 
> Karl Bochert
> 

Karl, which reverse functions are you comparing? 

all i'm trying to do is find a reverse function that will
swap from 2 or 3 to 100 or 10,000 to as many as 100 million
elements as quickly as possible.


--
jon

jxliv7 at hotmail.com

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

7. RE: Speed of global function

On 17 Aug 2003 at 3:10, jxliv7 at hotmail.com wrote:

> 
> 
> > FYI, reversiing a 20 element string with a built-in
> > function is a full 28 times faster.
> > A 100 element sequence reverses 38 times faster.
> > 
> > Karl Bochert
> > 
> 
> Karl, which reverse functions are you comparing? 
> 
I'm referring to a function that is built into the interpreter.
I compared Bach's built-in with the Eu routine in misc.e
In fairness, 38X is a best case number -- If the sequence being
reversed has multiple references, it is more like 10X.

There are several sequence operations
that are very suited to being done in the interpreter -- reverse_seq
move_elem, swap_elem, sort, etc all just re-arrange the
sequence, and thus do not have to fiddle with reference counts
or dereferencing of elements (and are very easy to implement!)
Functions which change the number of elements must ref and deref
elements and so gain much less
from being built-in : delete_elem 3X, toupper 9x etc.

> all i'm trying to do is find a reverse function that will
> swap from 2 or 3 to 100 or 10,000 to as many as 100 million
> elements as quickly as possible.
> 
Thats a serious sequence!!

Use Bach smile
(Of course that probably introduces other problems.)

Karl Bochert

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

8. RE: Speed of global function

> > all i'm trying to do is find a reverse function that will
> > swap from 2 or 3 to 100 or 10,000 to as many as 100 million
> > elements as quickly as possible.
> > 
> Thats a serious sequence!!
> 
> Use Bach smile
> (Of course that probably introduces other problems.)
> 
> Karl Bochert
> 

you're right. i installed Bach on August 5th, tried to run some
demos, etc., and maybe ran into those "other problems" you
mentioned above. i sat it aside until i could spend a little
time with it, which hasn't happened yet. maybe this weekend...


--
jon

jxliv7 at hotmail.com

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

9. RE: Speed of global function

On 17 Aug 2003 at 3:57, jxliv7 at hotmail.com wrote:

> 
> 
> > > all i'm trying to do is find a reverse function that will
> > > swap from 2 or 3 to 100 or 10,000 to as many as 100 million
> > > elements as quickly as possible.
> > > 
> > Thats a serious sequence!!
> > 
> > Use Bach smile
> > (Of course that probably introduces other problems.)
> > 
> > Karl Bochert
> > 
> 
> you're right. i installed Bach on August 5th, tried to run some
> demos, etc., and maybe ran into those "other problems" you
> mentioned above. i sat it aside until i could spend a little
> time with it, which hasn't happened yet. maybe this weekend...
> 
I was thinking of the lack of a translator, binding etc.
I am not aware of any bugs, but they are sure to exist.
Please let me know of any.

Also, be aware that Bach 2.0 is due out soon. It has more built-ins
and a number of other features.

Karl Bochert

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

10. RE: Speed of global function

Please take into account I tested this code with version 2.3.
Also, as Rob pointed out, all depends on the machine, the cache size and
speed, and many other circumstances.
Rob is the right person to anwer your question, I think.
Regards
----- Original Message -----
From: <jxliv7 at hotmail.com>
Subject: RE: Speed of global function


>
>
> 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...?
>
>
> --Test002.ex-----------
> include misc.e --for global reverse
>
> --integer a, b, c, d
> sequence a, b
> atom t, s, r
>
> --global function reverse(sequence s)
> ---- reverse the top-level elements of a sequence.
> ---- Thanks to Hawke' for helping to make this run faster.
> -- integer lower, n, n2
> -- sequence t
> -- n = length(s)
> -- n2 = floor(n/2)+1
> -- t = repeat(0, n)
> -- lower = 1
> -- for upper = n to n2 by -1 do
> -- t[upper] = s[lower]
> -- t[lower] = s[upper]
> -- lower += 1
> -- end for
> -- return t
> --end function
>
> function test1(sequence in) --my "copy" of global reverse above
> sequence out
> integer stop, start, mid
> stop = length(in)
> out = repeat(0, stop)
> mid = floor(stop/2)+1
> start = 1
> for i = stop to mid by -1 do
> out[start] = in[i]
> out[i] = in[start]
> start += 1
> end for
> return out
> end function
>
> --from genfunc.e, a set of general usage routines.
> --Version 1.9 - 2003/06/27
> --Author: Ricardo M. Forno
> function Test2(sequence a) --a different reverse
> sequence b --that i would think would be FASTER
> integer c
> c = length(a)
> b = repeat(0, c)
> for i = 1 to c do
> b[c] = a[i]
> c -= 1
> end for
> return b
> end function
>
> t = time() --my duplicate of global reverse
> for ii = 1 to 5 do --adjust iterations
> a = repeat(9, 9999999) --make file to be reversed
> b = test1(a)
> end for
> t = time() - t
>
> s = time() --Test2
> for ii = 1 to 5 do --adjust as above
> a = repeat(9, 9999999) --adjust same as file above
> b = Test2(a)
> end for
> s = time() - s
>
> r = time() --the global reverse routine
> for ii = 1 to 5 do --adjust as above
> a = repeat(9, 9999999) --adjust same as file above
> b = reverse(a)
> end for
> r = time() - r
>
>
> --
> jon
>
> jxliv7 at hotmail.com
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

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

11. RE: Speed of global function

Maybe you are trying to sort ascendingly a sequence and then reverse it to
get it in descending order. If that is the case, please try several sort
routines in my General Functions package that can do the job at once.
Or maybe you can modify your program to generate the sequence in the right
order in the first place. I don't know.
Regards.
----- Original Message -----
From: <jxliv7 at hotmail.com>
Subject: RE: Speed of global function


>
>
> > > all i'm trying to do is find a reverse function that will
> > > swap from 2 or 3 to 100 or 10,000 to as many as 100 million
> > > elements as quickly as possible.
> > >
> > Thats a serious sequence!!
> >
> > Use Bach smile
> > (Of course that probably introduces other problems.)
> >
> > Karl Bochert
> >
>
> you're right. i installed Bach on August 5th, tried to run some
> demos, etc., and maybe ran into those "other problems" you
> mentioned above. i sat it aside until i could spend a little
> time with it, which hasn't happened yet. maybe this weekend...
>
>
> --
> jon
>
> jxliv7 at hotmail.com
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu