1. power(a,0.5) v. sqrt(a)

I wrote the following program and ran it on EU v2.1 beta public domain ed=
:

include machine.e
integer num
atom t, p
tick_rate(1000)
num =3D rand(100)
set_rand(num)
t =3D time()
for i =3D 1 to 1000000 do
    p =3D power(rand(100),0.5)
end for
? time() - t
set_rand(num)
t =3D time()
for i =3D 1 to 1000000 do
    p =3D sqrt(rand(100))
end for
? time() - t

I got:

with power(a,0.5) 3.332492537 seconds
with sqrt(a) 1.192818361 seconds

These aren't exact times because I neglected to subtract the loop overhea=
d,
but they are correct relative to each other.  Bob, do you think we should=

optimize this?

Alan
  =

new topic     » topic index » view message » categorize

2. Re: power(a,0.5) v. sqrt(a)

Alan Tu writes:
... sqrt(a) is faster than power(a, 0.5) ...

I'll add it to my long wish list of low-priority optimizations.

Thanks,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu