1. Inconsistent exw.exe (was RE: Looking for the best "JOIN")
- Posted by bensler at mail.com Oct 22, 2001
- 363 views
2. Re: Inconsistent exw.exe (was RE: Looking for the best "JOIN")
- Posted by Robert Craig <rds at RapidEuphoria.com> Oct 23, 2001
- 331 views
Chris Bensler writes: > ...Third, I discovered that I would get extremely different > results using exw.exe, depending if a variable was > declared before the functions or not. > This shouldn't be!? > In DOS, there is no difference. > You might also note that Derek's routine was unaffected. I wasn't able to duplicate your results exactly, but I did see some large variability in timing when I tried various other things that shouldn't affect speed. About a year ago I thoroughly analyzed a benchmark very similar to yours. I noticed that when you have a tight loop that creates and destroys small sequences, many many times (only a benchmark would do this), then the performance can be strongly affected by trivial changes in the heap, such as declaring an extra variable. I put some changes into 2.3 as a result, but I don't think "real" programs are likely to be affected by this. If you have a wider variety of sequence lengths, and if you actually use the sequences for some purpose, then the performance should be pretty stable. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Inconsistent exw.exe (was RE: Looking for the best "JOIN")
- Posted by Igor Kachan <kinz at peterlink.ru> Oct 23, 2001
- 345 views
Ýòî ñîîáùåíèå â ôîðìàòå MIME ñîñòîèò èç íåñêîëüêèõ ÷àñòåé. ------=_NextPart_000_01C15C29.6737A8C0
4. Re: Inconsistent exw.exe (was RE: Looking for the best "JOIN")
- Posted by rforno at tutopia.com Oct 23, 2001
- 332 views
This is a multi-part message in MIME format. ------=_NextPart_000_0074_01C15C13.9FF126C0 charset="iso-8859-1" I slightly modified Derek's algorithm and made it marginally faster. I am attaching the modified TEST.EX and TEST2.EX files. But what really surprised me is the big difference in speed between EX and EXW. EXW is many times faster than EX, at least for these examples! Is there an explanation, Rob? Just to complicate the issue, I am attaching also a TEST3.EX file that deals with randomly varying lengths of sequences. ----- Original Message ----- From: <bensler at mail.com> To: "EUforum" <EUforum at topica.com> Sent: Monday, October 22, 2001 11:49 PM Subject: Inconsistent exw.exe (was RE: Looking for the best "JOIN") > > First of all, I found an algorithm that is slightly faster than Jiri's, just barely. > > Second, doing some bench testing, I found that Derek's is the fastest of the three when run in a DOS box. Jiri's suffers > most. > > Third, I discovered that I would get extremely different results using exw.exe, depending if a variable was declared before > the functions or not. > This shouldn't be!? > In DOS, there is no difference. > You might also note that Derek's routine was unaffected. > > I've attached my bench tests(which includes my version of join). TEST.EX and TEST2.EX are identical except TEST2.EX > declares a variable at the top of the file. > > Here are my bench results.... (iterations per second) > > TEST.EX | TEST2.EX > ------------|-------------- > WIN | WIN > ------------|-------------- > 318229 | 219441 -- my version > 210934 | 212506 -- Derek's > 305709 | 186280 -- Jiri's > ------------|-------------- > DOS | DOS > ------------|-------------- > 53299 | 54770 > 56681 | 56467 > 52735 | 52475 > ------------|-------------- > > Chris > > > ------=_NextPart_000_0074_01C15C13.9FF126C0 Content-Type: application/octet-stream; name="test2.ex" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="test2.ex" integer junk -------------------------------------------------------------------------= -------- -- FUNCTIONS -- function join(sequence s) sequence r if length(s)>1 then r=3Ds[1] for i =3D 2 to length(s) do r &=3Ds[i] end for return r elsif length(s) then return s[1] end if return {} end function function joinStrings(sequence s) integer l,a,b sequence t =20 if length(s)=3D0 then return s end if =20 l=3D0 for i =3D 1 to length(s) do l+=3Dlength(s[i]) end for t =3Drepeat(0,l) a=3D1 for i =3D 1 to length(s) do b =3D a + length(s[i]) - 1 t[a..b] =3D s[i] a =3D b+1 end for return t end function function join2(sequence s) sequence r r=3D{} for i =3D 1 to length(s) do r &=3Ds[i] end for return r end function function join3(sequence s) integer l,a,b sequence t l =3D 0 for i =3D 1 to length(s) do l +=3Dlength(s[i]) end for t =3D repeat(0,l) a =3D 0 for i =3D 1 to length(s) do b =3D a + length(s[i]) t[a + 1..b] =3D s[i] a =3D b end for return t end function -------------------------------------------------------------------------= -------- -- TEST CODE -- constant iteration_time=3D10 constant words1=3D{"abc","defghi","jklmnopqr","","st","u","vwxyz"} printf(1,"bench time: = %d:%02d\n",{floor(iteration_time*4/60),remainder(iteration_time*4,60)}) atom e sequence k integer x x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin(words1) end while printf(1,"join() <new> : %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3DjoinStrings(words1) end while printf(1,"joinStrings() <Derek's>: %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin2(words1) end while printf(1,"join2() <Jiri's> : %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin3(words1) end while printf(1,"join3() <Forno's>: %d iterations per = second\n",x/iteration_time) position(6,28) puts(1,"PRESS A KEY") while get_key()=3D-1 do end while ------=_NextPart_000_0074_01C15C13.9FF126C0 Content-Type: application/octet-stream; name="test.ex" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="test.ex" -------------------------------------------------------------------------= -------- -- FUNCTIONS -- function join(sequence s) sequence r if length(s)>1 then r=3Ds[1] for i =3D 2 to length(s) do r &=3Ds[i] end for return r elsif length(s) then return s[1] end if return {} end function function joinStrings(sequence s) integer l,a,b sequence t =20 if length(s)=3D0 then return s end if =20 l=3D0 for i =3D 1 to length(s) do l+=3Dlength(s[i]) end for t =3Drepeat(0,l) a=3D1 for i =3D 1 to length(s) do b =3D a + length(s[i]) - 1 t[a..b] =3D s[i] a =3D b+1 end for return t end function function join2(sequence s) sequence r r=3D{} for i =3D 1 to length(s) do r &=3Ds[i] end for return r end function function join3(sequence s) integer l,a,b sequence t l =3D 0 for i =3D 1 to length(s) do l +=3Dlength(s[i]) end for t =3D repeat(0,l) a =3D 0 for i =3D 1 to length(s) do b =3D a + length(s[i]) t[a + 1..b] =3D s[i] a =3D b end for return t end function -------------------------------------------------------------------------= -------- -- TEST CODE -- constant iteration_time=3D10 constant words1=3D{"abc","defghi","jklmnopqr","","st","u","vwxyz"} printf(1,"bench time: = %d:%02d\n",{floor(iteration_time*4/60),remainder(iteration_time*4,60)}) atom e sequence k integer x x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin(words1) end while printf(1,"join() <new> : %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3DjoinStrings(words1) end while printf(1,"joinStrings() <Derek's>: %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin2(words1) end while printf(1,"join2() <Jiri's> : %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin3(words1) end while printf(1,"join3() <Forno's>: %d iterations per = second\n",x/iteration_time) position(6,28) puts(1,"PRESS A KEY") while get_key()=3D-1 do end while ------=_NextPart_000_0074_01C15C13.9FF126C0 Content-Type: application/octet-stream; name="test3.ex" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="test3.ex" integer junk -------------------------------------------------------------------------= -------- -- FUNCTIONS -- function join(sequence s) sequence r if length(s)>1 then r=3Ds[1] for i =3D 2 to length(s) do r &=3Ds[i] end for return r elsif length(s) then return s[1] end if return {} end function function joinStrings(sequence s) integer l,a,b sequence t =20 if length(s)=3D0 then return s end if =20 l=3D0 for i =3D 1 to length(s) do l+=3Dlength(s[i]) end for t =3Drepeat(0,l) a=3D1 for i =3D 1 to length(s) do b =3D a + length(s[i]) - 1 t[a..b] =3D s[i] a =3D b+1 end for return t end function function join2(sequence s) sequence r r=3D{} for i =3D 1 to length(s) do r &=3Ds[i] end for return r end function function join3(sequence s) integer l,a,b sequence t l =3D 0 for i =3D 1 to length(s) do l +=3Dlength(s[i]) end for t =3D repeat(0,l) a =3D 0 for i =3D 1 to length(s) do b =3D a + length(s[i]) t[a + 1..b] =3D s[i] a =3D b end for return t end function -------------------------------------------------------------------------= -------- -- TEST CODE -- constant iteration_time=3D10 sequence words1, w words1 =3D {} for i =3D 1 to rand(100) do w =3D {} for j =3D 1 to rand(100) do w &=3D rand(256) - 1 end for words1 =3D append(words1, w) end for printf(1,"bench time: = %d:%02d\n",{floor(iteration_time*4/60),remainder(iteration_time*4,60)}) atom e sequence k integer x x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin(words1) end while printf(1,"join() <new> : %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3DjoinStrings(words1) end while printf(1,"joinStrings() <Derek's>: %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin2(words1) end while printf(1,"join2() <Jiri's> : %d iterations per = second\n",x/iteration_time) x=3D0 e=3Dtime()+iteration_time while e >=3D time() do x +=3D1 k =3Djoin3(words1) end while printf(1,"join3() <Forno's>: %d iterations per = second\n",x/iteration_time) position(6,28) puts(1,"PRESS A KEY") while get_key()=3D-1 do end while ------=_NextPart_000_0074_01C15C13.9FF126C0--
5. Re: Inconsistent exw.exe (was RE: Looking for the best "JOIN")
- Posted by Robert Craig <rds at RapidEuphoria.com> Oct 23, 2001
- 356 views
rforno writes: > EXW is many times faster than EX, at > least for these examples! Is there an explanation, Rob? Yes, I already explained it. exw is not faster. It's just luckier. Under the right conditions ex will be just as fast. For instance if I turn on time profiling, ex suddenly becomes just as fast as exw. Your results may vary. It just depends on a subtle property of the heap. When you buy the source, you'll be able to see what I'm talking about Remember - this phenomenon happens because this is an artificial program that does nothing useful. It just creates and destroys small sequences over and over again in a tight loop. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com