1. Comparison of Euphoria vs Perl, Python, PHP
- Posted by c.k.lester <euphoric at cklester.c??> Jun 11, 2008
- 855 views
- Last edited Jun 12, 2008
Can anybody create a Euphoria program based on the Perl/Python/PHP version found on this page: http://www.skitoy.com/p/performance-of-python-php-and-perl/160 It would be interesting to see how Euphoria fares against them these days.
2. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Bernie Ryan <xotron at blu?frog.?om> Jun 11, 2008
- 799 views
- Last edited Jun 12, 2008
c.k.lester wrote: > > Can anybody create a Euphoria program based on the Perl/Python/PHP version > found on this page: <a > href="http://www.skitoy.com/p/performance-of-python-php-and-perl/160">http://www.skitoy.com/p/performance-of-python-php-and-perl/160</a> > > It would be interesting to see how Euphoria fares against them these days. CK: I wrote a program in Euphoria that was so fast that it ran before I could finish it. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
3. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by c.k.lester <euphoric at ckl?ster.?om> Jun 11, 2008
- 785 views
- Last edited Jun 12, 2008
Bernie Ryan wrote: > c.k.lester wrote: > > Can anybody create a Euphoria program based on the Perl/Python/PHP version > > found on this page: <a > > href="http://www.skitoy.com/p/performance-of-python-php-and-perl/160">http://www.skitoy.com/p/performance-of-python-php-and-perl/160</a> > > It would be interesting to see how Euphoria fares against them these days. > CK: > I wrote a program in Euphoria that was so fast that it ran before I > could finish it. HAHA! :P Video or it didn't happen. :D
4. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at c??gar.com> Jun 11, 2008
- 843 views
- Last edited Jun 12, 2008
Well, I did not do as you suggested because I am too lazy to write new benchmarks. Although, I did just randomly pick one from the computer language shootout, nsieve: http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsieve&lang=all Here are the scores all on my PC (you cannot compare directly to the scores listed on the website due to different hardware). I downloaded the fastest of each language and then ran the benchmarks. Note, this was done using the unix "time" command, thus startup, parse time, execution and shutdown times are all measured: C (-O3) 0.464s Mono 0.527s Java 0.543s Euphoria (4.x) 1.303s (Translated) Euphoria (3.1.1) 1.306s (Translated) Euphoria (4.x) 1.809s Euphoria (3.1.1) 2.135s Python: 4.816s Lua: 7.204s Perl: 15.897s Ruby: 39.730s You cannot take these times directly, but you can take the rankings. For instance, we are better than Python, therefore you can look on the list and see we are better than: Lua, Pike, PHP, Groovy, Perl, JRuby, etc... You can see we are not as good as Java, so above the list things like OCaml, bigForth, Fortran are better than us. Take notice, though, that 4.0 is faster than 3.1.1. I have shown this many times but want to keep bringing attention to it to calm peoples fears that what we have added has caused Euphoria to be slow. -- Jeremy Cowgar http://jeremy.cowgar.com
5. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at cowga?.?om> Jun 11, 2008
- 806 views
- Last edited Jun 12, 2008
CK, I benchmarked PHP as well. Installed it just for you against my better judgment PHP: 11.940s -- Jeremy Cowgar http://jeremy.cowgar.com
6. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by c.k.lester <euphoric at ?kl?ster.com> Jun 12, 2008
- 811 views
Jeremy Cowgar wrote: > > CK, I benchmarked PHP as well. Installed it just for you against my better > judgment > > > PHP: 11.940s Wow. Thanks for the comparisons, Jeremy!
7. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Matt Lewis <matthewwalkerlewis at gma?l.c?m> Jun 12, 2008
- 814 views
c.k.lester wrote: > > Can anybody create a Euphoria program based on the Perl/Python/PHP version > found on this page: <a > href="http://www.skitoy.com/p/performance-of-python-php-and-perl/160">http://www.skitoy.com/p/performance-of-python-php-and-perl/160</a> > > It would be interesting to see how Euphoria fares against them these days. Not so good. Now, I didn't do anything special to try to optimize. I just used map.e and regex.e. I suspect that some of the slow down may be the conversion that has to happen between a euphoria sequence, and the C-string before it gets passed to PCRE. Also, the native perl hash and python dictionaries probably give them an edge. Here were my results: perl: real 0m26.361s user 0m25.726s sys 0m0.580s python: real 0m38.613s user 0m37.818s sys 0m0.760s euphoria: real 1m29.448s user 1m28.722s sys 0m0.620s translated euphoria: real 0m55.930s user 0m55.231s sys 0m0.636s Here's the code:
#!/usr/bin/exu include regex.e as re include map.e as map integer in sequence cmd cmd = command_line() in = open( cmd[3], "r" ) map:map first first = map:new(1000) integer FULL FULL = open( "full.txt", "w" ) regex MULTI_TOKEN, SINGLE_TOKEN MULTI_TOKEN = re:new( "^__MULTI_TOKEN__\\s+(\\S+)\\s+(.*)\\t?\\s*(\\d+)\\s*$" ) SINGLE_TOKEN = re:new( "^__SINGLE_TOKEN__\\s+(\\S+)\\s*\\t?\\s*(\\d+)\\s*$" ) object line object matches object one, two, three, three_plus while sequence( line ) entry do line = trim_tail( line ) matches = re:search( MULTI_TOKEN, line ) if sequence( matches ) then one = line[matches[2][1]..matches[2][2]] two = line[matches[3][1]..matches[3][2]] three = value(line[matches[4][1]..matches[4][2]]) three = three[2] three_plus = three + map:get( first, one, 0 ) first = map:put( first, one, three_plus ) printf( FULL, "%s %s\t%d\n", {one, two, three}) else matches = re:search( SINGLE_TOKEN, line ) if sequence( matches ) then one = line[matches[2][1]..matches[2][2]] two = value(line[matches[3][1]..matches[3][2]]) first = map:put( first, one, map:get( first, one, 0 ) + two[2] ) else printf( 1, "Unknown: {%s}\n", {line} ) end if end if entry line = gets(in) end while close( FULL ) close( in ) integer FIRST FIRST = open( "first.txt", "w" ) sequence keys keys = map:keys( first ) for i = 1 to length( keys ) do printf( FIRST, "%s\t%d\n", {keys[i], map:get( first, keys[i], 0)}) end for close( FIRST )
And here's how I generated the test data:
include machine.e set_rand( 271828183 ) function make_word() integer len sequence word len = rand( 20 ) + 1 word = "" for i = 1 to len do word &= 'a' + rand(26) - 1 end for return word end function sequence words words = repeat( {}, 1000 ) for k = 1 to 1000 do words[k] = make_word() end for function get_word() return words[rand(1000)] end function integer fn fn = open( "line_test.txt", "w" ) for i = 1 to 5000000 do if rand(2) = 1 then -- multi token printf( fn, "__MULTI_TOKEN__ %s %s %s\t%d\n", {get_word(), get_word(), get_word(), rand(20)} ) else -- single token printf( fn, "__SINGLE_TOKEN__ %s \t%d\n", {get_word(), rand(20)} ) end if end for close( fn )
8. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at c?wgar.?om> Jun 12, 2008
- 785 views
Matt Lewis wrote: > > Not so good. Now, I didn't do anything special to try to optimize. I > just used map.e and regex.e. I suspect that some of the slow down may > be the conversion that has to happen between a euphoria sequence, and > the C-string before it gets passed to PCRE. Also, the native perl hash > and python dictionaries probably give them an edge. > I wonder how much difference it would be if we enabled/provided the pcre_optimize function, which allows pcre to once look at the regular expression and optimize it instead of doing it on every search. But I suspect your right. I'm going to do a little test of python's dict vs our map to see. -- Jeremy Cowgar http://jeremy.cowgar.com
9. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at cowg??.com> Jun 12, 2008
- 787 views
A very dumb check of the hash implementations between Python and Euphoria: count = 100000 dict = {} for i in range(count): dict[str(i)] = i for i in range(count): c = dict[str(i)] print(c)
--include sequence.e include map.e as map integer c map:map m constant count = 100000 m = map:new() for i = 1 to count do m = map:put(m, sprint(i), i) end for for i = 1 to count do c = map:get(m, sprint(i), 0) end for ? c
[jeremy@jdesk ~]$ time python hash.py 99999 real 0m0.233s user 0m0.220s sys 0m0.010s [jeremy@jdesk ~]$ time exu hash.ex 100000 real 0m1.852s user 0m1.850s sys 0m0.003s [jeremy at jdesk ~]$ time ./hash 100000 real 0m1.573s user 0m1.563s sys 0m0.010s -- Jeremy Cowgar http://jeremy.cowgar.com
10. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at cowga?.?om> Jun 12, 2008
- 803 views
Matt, Something is wrong with map:new()... On your example, I shaved 15 seconds off (comparing to my own box) by using map:new() instead of map:new(1000)... It took 15 seconds for map:new(1000) to return!!?!? -- Jeremy Cowgar http://jeremy.cowgar.com
11. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at c?w?ar.com> Jun 12, 2008
- 779 views
Jeremy Cowgar wrote: > > }}} <eucode> > --include sequence.e > include map.e as map > > integer c > map:map m > constant count = 100000 > m = map:new() > > for i = 1 to count do > m = map:put(m, sprint(i), i) > end for > > for i = 1 to count do > c = map:get(m, sprint(i), 0) > end for > > ? c > </eucode> {{{ > Oh, I forgot to show the difference if not using sprint(i) but i directly. [jeremy@jdesk ~]$ time exu hash.ex 100000 real 0m1.010s user 0m1.003s sys 0m0.003s vs. [jeremy@jdesk ~]$ time exu hash.ex 100000 real 0m1.852s user 0m1.850s sys 0m0.003s That's quite a difference! -- Jeremy Cowgar http://jeremy.cowgar.com
12. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by c.k.lester <euphoric at ckleste?.?om> Jun 12, 2008
- 808 views
Matt Lewis wrote: > c.k.lester wrote: > > Can anybody create a Euphoria program based on the Perl/Python/PHP version > > found on this page: <a > > href="http://www.skitoy.com/p/performance-of-python-php-and-perl/160">http://www.skitoy.com/p/performance-of-python-php-and-perl/160</a> > > It would be interesting to see how Euphoria fares against them these days. > Not so good. Well, hopefully the devs will take this as a mandate to improve Euphoria core for speed in this domain. Or no?
13. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at cowgar?co?> Jun 12, 2008
- 783 views
c.k.lester wrote: > > Matt Lewis wrote: > > c.k.lester wrote: > > > Can anybody create a Euphoria program based on the Perl/Python/PHP version > > > found on this page: <a > > > href="http://www.skitoy.com/p/performance-of-python-php-and-perl/160">http://www.skitoy.com/p/performance-of-python-php-and-perl/160</a> > > > It would be interesting to see how Euphoria fares against them these days. > > Not so good. > > Well, hopefully the devs will take this as a mandate to improve Euphoria core > for speed in this domain. > > Or no? It gives us something to look at, but bear in mind this not new to 4.0, we have lived with this probably since Euphoria's conception. -- Jeremy Cowgar http://jeremy.cowgar.com
14. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by c.k.lester <euphoric at ?klester?com> Jun 12, 2008
- 763 views
Jeremy Cowgar wrote: > c.k.lester wrote: > > Matt Lewis wrote: > > > Not so good. > > Well, hopefully the devs will take this as a mandate to improve Euphoria > > core > > for speed in this domain. > > Or no? > It gives us something to look at, but bear in mind this not new to 4.0, we > have > lived with this probably since Euphoria's conception. We lived without GOTO also. And optional parameters. But those things are said to improve Euphoria. I think a speed boost in core where we are competitive in the text processing domain is even better. Of course, Rob maybe have tweaked the heck outta core and we're about as fast as we'll ever be. But I hope not. :)
15. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Jeremy Cowgar <jeremy at ?owgar?com> Jun 12, 2008
- 788 views
c.k.lester wrote: > > We lived without GOTO also. And optional parameters. But those things > are said to improve Euphoria. I think a speed boost in core where we are > competitive in the text processing domain is even better. > > Of course, Rob maybe have tweaked the heck outta core and we're about > as fast as we'll ever be. But I hope not. :) Yes, I would say the core is as fast as it is ever going to be. Now the speed improvement that would be required to make this one test (again it's just 1 test) shine would be to move hash tables into C code, but, many will think that is bloating the interpreter. It's a balancing act. For this one test, I can show you 100 others that we are faster. There is a common belief that benchmarking is evil. Also, Matt did say that he did not try to optimize anything. Maybe before we get too excited about making mass changes we should concentrate on making what we have work. goto has been in the feature request bin for years. optional parameters makes coding much easier and less functions to learn and use. We *are* a volunteer staff. If you would like to concentrate on making this faster, you can do so. You are a dev on the Euphoria project and the major problem right now seems that map is not as fast as Python's, so it's Euphoria code that needs updated. Jump in! -- Jeremy Cowgar http://jeremy.cowgar.com
16. Re: Comparison of Euphoria vs Perl, Python, PHP
- Posted by Matt Lewis <matthewwalkerlewis at ?mail.?om> Jun 12, 2008
- 852 views
Jeremy Cowgar wrote: > > Matt, > > Something is wrong with map:new()... On your example, I shaved 15 seconds off > (comparing to my own box) by using map:new() instead of map:new(1000)... It > took 15 seconds for map:new(1000) to return!!?!? Heh. Told you I didn't do much. Or even have a good understanding of map.e. :) I just figured that I was going to have a lot of keys, and wanted to avoid hash collisions. I reverted to a regular map:new(), and got 7 seconds faster. Then I turned off type checking, and got another 12 seconds. Then I added a function in map.e to do the addition for me, instead of having to get the value, do the addition, and then put the value (it's almost identical to put(), but if the value exists, it adds to the existing value rather than replaces it). That bought me another 4 seconds. Before: real 1m29.448s user 1m28.722s sys 0m0.620s After: real 1m6.097s user 1m4.928s sys 0m0.688s Matt