RE: Speed of global function

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

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu