Re: simple eurphoria question

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

Ricardo M. Forno wrote:
>
> Hi Chris.
> Maybe there should be some difference between your benchmarks and mine.
> My PC has an AMD 2800 chip, and I'm usig EU 2.4 :)
> Regards.

I'm using a PIV 2.53Ghz but I don't think that should really matter.
In these tests, I've changed the MAX from 50000000 to 5000000 so they are
faster, but the results are consistent with what I get when using the larger
iterations.

Using this code...
constant MAX = 5000000
atom t, x

function f1(atom a)
    return a - remainder(a,1)
end function

function f2(atom a)
  if a < 0 then
  	return - floor(- a)
  end if
    return floor(a)
end function

t = time()
for i = 1 to MAX do
    x = f1(89.76)
end for
printf(1, "f1 = %f\n", time() - t)

t = time()
for i = 1 to MAX do
    x = f2(89.76)
end for
printf(1, "f2 = %f\n", time() - t)

if getc(0) then end if


Using 2.3 the results are:
f1() = 1.50
f2() = 1.42

Using 3.0.1 the results are:
f1() = 1.37
f2() = 1.54

Using this code:
constant MAX = 5000000
atom t, x

function f1(atom a)
    return a - remainder(a,1)
end function

function f2(atom a)
  if a < 0 then
  	return - floor(- a)
  end if
    return floor(a)
end function

function f3(atom a)
  if a >= 0 then
    return floor(a)
  else
  	return - floor(- a)
  end if
end function

t = time()
for i = 1 to MAX do
    x = f1(89.76)
end for
printf(1, "f1 = %f\n", time() - t)

t = time()
for i = 1 to MAX do
    x = f2(89.76)
end for
printf(1, "f2 = %f\n", time() - t)

t = time()
for i = 1 to MAX do
    x = f3(89.76)
end for
printf(1, "f3 = %f\n", time() - t)

if getc(0) then end if


Using 2.3 the results are:
f1() = 1.52
f2() = 1.41
f3() = 1.44

Using 3.0.1 the results are:
f1() = 1.42
f2() = 1.52
f3() = 1.45

When I use this code:
constant MAX = 5000000
atom t, x

function f1(atom a)
    return a - remainder(a,1)
end function

function f3(atom a)
  if a >= 0 then
    return floor(a)
  else
  	return - floor(- a)
  end if
end function

function f2(atom a)
  if a < 0 then
  	return - floor(- a)
  end if
    return floor(a)
end function

t = time()
for i = 1 to MAX do
    x = f1(89.76)
end for
printf(1, "f1 = %f\n", time() - t)

t = time()
for i = 1 to MAX do
    x = f3(89.76)
end for
printf(1, "f3 = %f\n", time() - t)

t = time()
for i = 1 to MAX do
    x = f2(89.76)
end for
printf(1, "f2 = %f\n", time() - t)

if getc(0) then end if


(note that the results for f3() are displayed before f2() in this example)
Using 2.3 the results are:
f1() = 1.50
f3() = 1.40
f2() = 1.46

Using 3.0.1 the results are:
f1() = 1.39
f3() = 1.48
f2() = 1.45

Chris Bensler
~ The difference between ordinary and extraordinary is that little extra ~
http://empire.iwireweb.com - Empire for Euphoria

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

Search



Quick Links

User menu

Not signed in.

Misc Menu