Re: Benchmark Python vs Euphoria.
On Thu, 05 Jan 2006 15:53:35 -0800, Jean-Francois Soucaille
<guest at RapidEuphoria.com> wrote:
>With Python, loops are 'while' based rather 'for' based for avoiding the range
>function overhead.
While these are most likely "near enough", I somehow doubt they
actually do the same job:
>
>#####Python code
> S=0.
> while n<20:
> S=S+increment
> increment=increment*x/n
> n=n+1
>######Euphoria code
> sum=1.0
> for i=1 to 20 do
> delta=delta*x/i
> sum+=delta
> end for
No biggie, I would bet my house on your timings being within 1%, erm
make that 10%, but it is important to be certain to compare like for
like. S/sum start with different values, delta/increment is calculated
before rather than after being added to sum/S, and it looks to me like
the Python loop is one shorter (< rather than <=), though different
start values probably cause the same results to be given.
Yes, I know it doesn't really matter, my apologies for nit-picking.
Regards,
Pete
|
Not Categorized, Please Help
|
|