1. Re[2]: Eu Interpreted
- Posted by aku at inbox.as Aug 15, 2001
- 417 views
So, as I said before, why not make value() as built in routine! because it is the most used include-file function. Benchmark (exw and lua for windows) eu: include get.e object x,y x=time() for i=1 to 100000 do y = value("5001287.589") end for printf(1, "%.2g", time()-x) -- result: 7.1 seconds lua: x = clock() for i=1,100000 do tonumber("5001287.589") end print(clock()-x) -- result: 2.36 seconds R> By the way, in search.ex I have a much faster routine, R> that is not generic.
2. Re: Re[2]: Eu Interpreted
- Posted by Robert Craig <rds at RapidEuphoria.com> Aug 15, 2001
- 403 views
Aku writes: > So, as I said before, why not make value() as built in routine! > because it is the most used include-file function. <snip: yet another benchmark of a C routine in Lua vs an interpreted Euphoria routine> Perhaps value() is your most used routine, but I don't agree that it is for most people. I like to write library routines in Euphoria, where people can choose to include them or not, and can see and modify the source if they want. It's also much easier to write sequence-manipulation code in Euphoria than in C. In other interpreted languages, such as Lua, there is a huge speed penalty for executing statements in the interpreted language rather than in C. This is much less true of Euphoria. It's tempting to write things like value() or "read a whole file in one gulp" in C, but where do you draw the line? The vast majority of programs do not wish to read an entire large file into memory in one shot. They want to read a character, or line, or small chunk at a time and process it. Lua's supposed advantage in file I/O would evaporate if you tried a character-at-time or line-at-a-time benchmark. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Re[2]: Eu Interpreted
- Posted by Irv Mullins <irvm at ellijay.com> Aug 15, 2001
- 419 views
On Wednesday 15 August 2001 11:13, Robert Craig wrote: > It's tempting to write things like value() > or "read a whole file in one gulp" in C, > but where do you draw the line? > The vast majority of programs do not wish to > read an entire large file into memory in one shot. > They want to read a character, or line, or small chunk > at a time and process it. Lua's supposed advantage in > file I/O would evaporate if you tried a > character-at-time or line-at-a-time benchmark. Reading line-by-line, Lua is still twice as fast as Euphoria. Regards, Irv
4. Re: Re[2]: Eu Interpreted
- Posted by Robert Craig <rds at RapidEuphoria.com> Aug 15, 2001
- 380 views
Irv Mullins writes: > Reading line-by-line, Lua is still twice as fast as Euphoria. If you leveled the playing field, and had them both reading a character at a time, I bet Lua would read slower. For those who aren't bored with this topic yet, here's a tweaked version of get_bytes() that's about 30% faster in most cases. I've updated my copy of get.e for 2.3. global function get_bytes(integer fn, integer n) -- Return a sequence of n bytes (maximum) from an open file. -- If n > 0 and fewer than n bytes are returned, -- you've reached the end of file. sequence s integer c if n = 0 then return {} end if c = getc(fn) if c = -1 then return {} end if s = repeat(c, n) for i = 2 to n do s[i] = getc(fn) end for if s[n] != -1 then return s else -- trim eof's while s[n] = -1 do n -= 1 end while return s[1..n] end if end function Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com