1. Speed test
- Posted by rforno at tutopia.com Sep 01, 2001
- 454 views
This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C1327E.46E70D60 charset="iso-8859-1" The enclosed file tests the speed of five different methods of doing the same thing. According to the results, it seems that using "parallel" sequences is faster than using sequences of sequences, when possible, although it might be less clean. ------=_NextPart_000_0015_01C1327E.46E70D60 name="Test.ex" filename="Test.ex" constant M = 1000 sequence x, y, a, b, c, d procedure one(integer n) x = rand(repeat(repeat(M, 4), n)) for i = 1 to n do x[i][1] += x[i][2] - x[i][3] + x[i][4] end for end procedure procedure two(integer n) a = rand(repeat(M, n)) b = rand(repeat(M, n)) c = rand(repeat(M, n)) d = rand(repeat(M, n)) for i = 1 to n do a[i] += b[i] - c[i] + d[i] end for end procedure procedure three(integer n) a = rand(repeat(M, n)) b = rand(repeat(M, n)) c = rand(repeat(M, n)) d = rand(repeat(M, n)) a += b - c + d end procedure procedure four(integer n) x = rand(repeat(repeat(M, 4), n)) for i = 1 to n do y = x[i] y[1] += y[2] - y[3] + y[4] x[i] = y end for end procedure procedure five(integer n) x = rand(repeat(repeat(M, 4), n)) for i = 1 to n do y = x[i] x[i][1] += y[2] - y[3] + y[4] end for end procedure procedure test() integer n, k atom t0 k = 500 n = 1000 t0 = time() for i = 1 to k do one(n) end for ? time() - t0 t0 = time() for i = 1 to k do two(n) end for ? time() - t0 t0 = time() for i = 1 to k do three(n) end for ? time() - t0 t0 = time() for i = 1 to k do four(n) end for ? time() - t0 t0 = time() for i = 1 to k do five(n) end for ? time() - t0 end procedure test() ------=_NextPart_000_0015_01C1327E.46E70D60--
2. Re: Speed test
- Posted by Derek Parnell <ddparnell at bigpond.com> Sep 01, 2001
- 444 views
Yes, I often use parallel lists too. Vertical slicing becomes an issue then. Pity we don't have any neat ways of do that yet. ----- Original Message ----- From: <rforno at tutopia.com> To: "EUforum" <EUforum at topica.com> Subject: Speed test > > The enclosed file tests the speed of five different methods of doing the > same thing. According to the results, it seems that using "parallel" > sequences is faster than using sequences of sequences, when possible, > although it might be less clean. > > > >
3. Re: Speed test
- Posted by rforno at tutopia.com Sep 02, 2001
- 443 views
I'm afraid I don't understand what do you call "vertical slicing". If one uses parallel sequences, let's say x, y, z, then there is only one way to refer to each element of these, namely x[i], etc. Please give an example of what you mean. Regards. ----- Original Message ----- From: "Derek Parnell" <ddparnell at bigpond.com> To: "EUforum" <EUforum at topica.com> Subject: Re: Speed test > > Yes, I often use parallel lists too. Vertical slicing becomes an issue then. > Pity we don't have any neat ways of do that yet. > > ----- Original Message ----- > From: <rforno at tutopia.com> > To: "EUforum" <EUforum at topica.com> > Sent: Saturday, September 01, 2001 1:37 PM > Subject: Speed test > > > > The enclosed file tests the speed of five different methods of doing the > > same thing. According to the results, it seems that using "parallel" > > sequences is faster than using sequences of sequences, when possible, > > although it might be less clean. > > > > > >
4. Re: Speed test
- Posted by Igor Kachan <kinz at peterlink.ru> Sep 04, 2001
- 458 views
Hello Ricardo, > I'm afraid I don't understand what do you call > "vertical slicing". If one uses parallel sequences, > let's say x, y, z, then there is only one way to > refer to each element of these, namely x[i], etc. > Please give an example of what you mean. This case is described in refman.doc file. See please below: --program vert.ex sequence a,c a={{01, 02, 03, 04}, --> row 1 {05, 06, 07, 08}, --> row 2 {09, 10, 11, 12}, --> row 3 {13, 14, 15, 16}} --> row 4 -- 1 2 3 4 <-- columns 1..4 ? a[3][2..3] -- this is a simple expression for any row function b(sequence s, integer n) sequence v v=repeat(0,length(s)) for i=1 to length(s) do v[i]=s[i][n] end for return v end function c=b(a,3) -- but to take a column you must write ? c [3..4] -- your own function. -- this is a 'vertical slicing problem' -- in Euphoria function d(sequence s, integer n, integer m, integer l) sequence v v=repeat(0,length(s)) for i=1 to length(s) do v[i]=s[i][n] end for return v[m..l] end function ? d(a,3,3,4)-- this complicated expression for columns -- has 10 elements -- but simple one for rows has same 10 elements, -- see above -- end of program Maybe, these functions above are useful too, use if so. Regards, Igor Kachan kinz at peterlink.ru