Re: Last Element Reference

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 21 Sep 2003 at 13:49, Lucius Hilley wrote:

<snip>

> Hip-Hip Hooray!
> Hip-Hip Hooray!
>     Cheers to RC for speaking again.  Now we have even more of his
> view against negative subscripting.

See below for benchmark results.
 
> 
> In the words of the legendary Hulk Hogan. "I hear you brother."
> 
>         Lucius L. Hilley III - Unkmar
>         Not a wrestling fan.
> 
> ----- Original Message ----- 
> From: "Robert Craig" <rds at RapidEuphoria.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Sunday, September 21, 2003 01:16 AM
> Subject: Re: Last Element Reference
> 
> 
> > Pete Lomax wrote:
> > > Rob, from your knowledge of the internals of Euphoria, is my assertion
> > > wrong that the required change would be:
> > > if a<0 then a+=length()+1
> > > -- normal bounds checking
> > > I'm just interested, feel free to say yes and not do it blink
> > 
> > Yes that looks about right, and that's another small point
> > against negative subscripts. Having to perform
> > the test:
> >     if a < 0 then
> > looks trivial, but subscripting is THE most frequently
> > performed operation. Adding two machine instructions
> > would slow down many programs by a couple of percent
> > when interpreted, and maybe 10 percent when translated,
> > even if negative subscripts are never used
> > in that program. It would also add to the size of
> > translated code, although I could try
> > to optimize some translated code by "proving" that a
> > negative subscript will not occur in a given statement.
> > 
Some actual results for the Eu slicing benchmark using the Bach 
interpreter.

a) Bach (with negative index) vs. Eu  --  95%
b) Bach (without negative index)  vs. Eu  -- 98%
     negative index caused 3% slowdown
c) Bach (using a negative index in the benchmark)  Vs. Eu  140%
     uses of negative index are much faster.

Having thought that Bach used to do better on this test, I
rearranged the C code a little ---

a) Bach (with negative index) vs. Eu  --  103% (what I remember)
b) Bach (without negative index)  vs. Eu  -- 102%
     negative index was faster!!
c) Bach (using negative index in the benchmark  Vs. Eu  146%

It would seem (as usual) that the speed of Eu is heavily influenced
by the Watcom optimizer. Adding one or two  machine instructions
("if (a < 0)"  may require many other changes to keep the speed up.
 


Karl Bochert

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu