1. How fast is Euphoria's string processing?

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();
    }
}

new topic     » topic index » view message » categorize

2. Re: How fast is Euphoria's string processing?

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: How fast is Euphoria's string processing?

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...

new topic     » goto parent     » topic index » view message » categorize

4. Re: How fast is Euphoria's string processing?

Thanks Derek ~

that's indeed fast! And I understand I could even be translated to C and
compiled for an additional boost...

Thanks
Kai

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu