Re: Benchmark Python vs Euphoria.

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

On an Athlon32 machine clocked at 1.8 GHz, 1 million iterations of an
exponential
based on a 20 terms development runs in 3s with Euphoria vs. around 20s in
Python,
with or without JIT. 
With Python, loops are 'while' based rather 'for' based for avoiding the range
function overhead.

#####Python code
 
from os import times

t_init=times()
k=1
while k<1000000:
    S=0.
    increment=1.
    x=1.
    n=1
    while n<20:
        S=S+increment
        increment=increment*x/n
        n=n+1
    k=k+1
print S
t_end=times()
print(t_end[1]-t_init[1])

######Euphoria code

include get.e
atom t_init
atom x,delta,sum

t_init=time()
for k=1 to 1000000 do
x=1.0
delta=1.0
sum=1.0

        for i=1 to 20 do
                delta=delta*x/i
                sum+=delta
        end for
end for
atom dummy
printf(1,"%16.14f\n",sum)
printf(1,"%f",time()-t_init)

dummy=wait_key()

Regards

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

Search



Quick Links

User menu

Not signed in.

Misc Menu