1. Re: Faster Please .. The End
- Posted by "Kat" <gertie at visionsix.com> Jan 13, 2004
- 375 views
On 12 Jan 2004, at 23:41, Euman wrote: > > I think this one will be hard to beat, Kat can you with strtok.e? Well, i figured you could run the tests, since you came up with the new code, and you have strtok? But really, strtok has more functionality that just what you wrote, since it must do more. And i am adding some more... if i don't over-engineer it, of course. "Function versatility" vs "can anyone remember the syntax of using it". Your "atom x" must be an object in strtok, because it can be passed several delimiters, as well as how to behave with those delimiters, much like sorttok is passed levels and case-sensitivity params. Basically, i reduced the importance of speed in strtok (past a certain level), in favor of function ability. The best a user of strtok.e can do is keep a copy of the parsed string, so calls to gettok(), repltok(), remtok(), etc do not haveto reparse the string for each call. Except in cases of multiple delimiters, where the string might need to be rebuilt with the (multiple and possibly randomly placed) delimiters put back in deparse(), this is the greatest speed increase in real life practice. Just about anything else remarkable in speed will come from improvements RobC could put in Eu itself, in memory management and calling overhead. Kat > -- Coloborative effort Ron Austin, H.W Overman 2004 > global function sNestDelimited(sequence s, atom x) > integer len, start, endx > sequence dseq,dl > dseq={} > len = length(s) > start = 1 > for i = 1 to len do > if s[i] = x then > endx = i-1 > dseq &= {s[start..endx]} > start = i+1 > end if > end for > return dseq > end function > > ----------- test function --------- > sequence dl, test, test1 > object data > integer stop > atom t > > dl=repeat(127,1) > test = {} > test1 = "Ron Austin"&dl&"H.W Overman"&dl&"Euphoria"&dl&"Programmers"&dl > for i = 1 to 5000 do > test &= test1 & "Field "&sprintf("%d",i)&dl > end for > t = time() > data=sNestDelimited(test, 127) > t = time() - t > puts(1, "Time: " & sprintf("%0.3f", t)) > puts(1,'\n') > for i=1 to 4 do > puts(1, data[i]&'\n') > end for > stop=getc(0) > > > > TOPICA - Start your own email discussion group. FREE! >