Re: Optimization

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

Davi Figueiredo wrote:
> Hello all,
> While doing some simple benchmarks in Euphoria, I came across
> a very interesting thing. I ran a program like this:
> procedure proc1()
> procedure proc2()
> procedure proc3()
> The three procedures do basically the same thing, but proc1()
> has only one for loop, while proc2() has two of them and
> proc3() has four for loops. So I supposed proc2() would be
> slower than proc1() and proc3() would be slower than proc2().
> However, proc1() took about 6 seconds to run and proc2() took
> about 7.8 seconds (all right until now), but proc3() took
> only about 5.3 seconds!
my results do not match yours, as seen below.
i'm not referring to the actual seconds, but the relationship
instead... proc1 seems to have won versus proc2 & proc3.

i also tested an additional proc4 which is:
procedure proc4()
atom foo
    foo=0
    for temp=1 to 15000000 do
        foo=foo+4
    end for
    ? foo
end procedure

and as you can see from the results below, proc4
beat 1,2,&3 by a very serious margin, with 1
coming in second...
60000000
proc1() took 7.09 seconds
60000000
proc2() took 8.35 seconds
60000000
proc3() took 8.51 seconds
60000000
proc4() took 2.64 seconds

> The only explanation I could find is that there is some kind
> of optimization for for loops with a single statement inside.
what version of EU are you running, and on what machine,
and under what conditions? (under a dos box? with other things
running? etc)
i ran this on a P200mmx, in a dos box that (for all intentent
purposes) takes full control of the machine due to the pif
settings i have set for command.com, and I had
nothing running in my tray that would use clock ticks.
i ran the test several times, (as i always do btw) and
the answers varied between tests just the barest fraction...
like 7.09 versus 7.07 kinda thing....

if we cannot reconcile this, then perhaps we could rerun the
tests in *pure* dos with equal copies of euphoria (2.0)

*pure* dos=(reboot, f8 @ "starting win95", choose 5,
    load the fewest drivers possible
    [himem, sets {like set tmp=c:\tmp stuff}, path,
     prompt, smartdrv and defnly no mouse, no cdrom,
     and no soundcard stuff]
then run the test several times to make sure that
ex.exe and foobar.ex is cached...

and if all that *still* doesn't reconcile the win,
place, and show rankings of proc1..4() then we
can start scratching our heads :)

--Hawke'

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

Search



Quick Links

User menu

Not signed in.

Misc Menu