Re: Looking for the best "JOIN"
- Posted by rforno at tutopia.com Oct 24, 2001
- 389 views
Yes, my routine takes into account an empty input sequence, not explicitly, but it does. Try it. In this case, it is a bit slower, but I think it doesn't matter... ----- Original Message ----- From: <bensler at mail.com> To: "EUforum" <EUforum at topica.com> Subject: RE: Looking for the best "JOIN" > > First of all, > > Igor, the entire reason I attempted to improve on the JOIN algorithm, was because I thought the same thing as you :), that it isn't necessary to have a return sequence, when you can utilize the first element of the input sequence. But this proves to be MUCH slower because EU has to shuffle the data in the sequence too much(this is my assumption anyways). > > Rforno, your version doesn't take into account empty sequences for input. > > Now, I made a NEW bench test, which should prove to be much more accurate. It's attached. > > Here are my results. > (For EXE.EXE only) > > 10000 iterations of operations on 10000 random sequences using 4 different versions of join() > (Total of 4000000 iterations) > > my version : 139180 iterations per second > Derek's : 142229 > Jiri's : 133288 > Igor's : 71904 > > The results are fairly close in this test but I found that on the whole, Derek's routine was much more consistent, and always greater than the others. > > Using not quite as extreme of a test, the results are similar from a DOS box. I didn't test pure DOS. > > Also, I was able to improve Derek's routine by about 8%. > He originally had it to test for an empty input sequence at the start of the routine. > This means that his routine requires a conditional jump every time the input sequence is NOT empty. > I just reversed it, so it only branches when the input sequence IS empty. > > There ya go Euman :) > Derek's routine is fastest(with minor modification) > > function joinStrings(sequence s) > integer l,a,b > sequence t > > if length(s) then > l=0 > for i = 1 to length(s) do > l+=length(s[i]) > end for > > t =repeat(0,l) > a=1 > for i = 1 to length(s) do > b = a + length(s[i]) - 1 > t[a..b] = s[i] > a = b+1 > end for > > return t > end if > return s > end function > > Chris > -- > > >