1. How fast is Euphoria's string processing?
- Posted by Kai <platysternon at h?tma?l.com> Nov 07, 2007
- 594 views
Hi all ~ am not a Euphoria user (yet) but have come across claims that Euphoria is supposedly very fast when it comes to string processing (and, of course, the programmer knows what (s)he is doing). Over on the Rebol mailing list they have just started a friendly mini "shootout" between Java and Rebol, using the tiny Java program below. I was wondering if one of the gurus on this forum could whip up the equivalent in Euphoria for comparison purposes? Thanks to all who do! Cheers Kai //-------------------------------------------------------------------------- public class Prova1 { public Prova1() { System.out.println("START..."); StringBuffer finale = new StringBuffer(); for(int i=1; i<10001; i++) { StringBuffer str = new StringBuffer(); for(int j=1; j<501; j++) { str.append(String.valueOf(i)).append(",").append(String.valueOf(j)).append("-"); } finale.append(str.substring(1, 5)); } System.out.println("COMPLETED!!!"); System.out.println(finale.toString()); System.out.println(finale.length()); } public static void main(String[] args) { new Prova1(); } }
2. Re: How fast is Euphoria's string processing?
- Posted by Derek Parnell <ddparnell at bigpond?com> Nov 07, 2007
- 540 views
Kai wrote: > > Hi all ~ > > I was wondering if one > could whip up the equivalent in Euphoria for comparison purposes? -- start of program -- sequence str sequence finale atom st,et puts(1,"START...\n") st = time() -- Initialize the result to an empty string finale = "" -- repeat for 10,000 times for i=1 to 10000 do -- Initialize the temporary string str = "" -- repeat for 500 times for j = 1 to 500 do -- append the string repesentations of i and j str &= sprintf("%d,%d-", {i,j}) end for -- Append the first five characters of the temp str to the result finale &= str[1..5] end for et = time() puts(1, "COMPLETED!!!\n") printf(1, "%s\n%d\n%f seconds\n", {finale, length(finale), et-st}) -- end of program -- -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
3. Re: How fast is Euphoria's string processing?
- Posted by Matt Lewis <matthewwalkerlewis at gmai??com> Nov 07, 2007
- 529 views
Derek Parnell wrote: >
-- Append the first five characters of the temp str to the result finale &= str[1..5]
Minor nitpick: Java's String.substr() uses 0-based indexing. So the correct version would be:
finale &= str[2..6]
Matt /too much java going on in my life right now...
4. Re: How fast is Euphoria's string processing?
- Posted by Kai <platysternon at h?tmai?.com> Nov 07, 2007
- 551 views
Thanks Derek ~ that's indeed fast! And I understand I could even be translated to C and compiled for an additional boost... Thanks Kai