[Israel.pm] python/c/perl cheak.

Shlomi Fish shlomif at iglu.org.il
Sat Oct 30 05:38:59 PDT 2004


On Saturday 30 October 2004 13:01, amit sides wrote:
> http://www.whatsup.org.il/index.php?name=PNphpBB2&file=viewtopic&t=18375
> <http://www.whatsup.org.il/index.php?name=PNphpBB2&file=viewtopic&t=18375>
>
> i want to see what you guys think about this one.
>
> the guy tested with 3 littel programs that cound from 3 to 1000000 and
> do a math action with 3 diffrent languages.
> it took to perl more time then the others.
> i think its not a professional cheak but what do you think ?

Well, the problem is that the Perl program was written badly. You can see my 
comment there (search for "shlomif") and see how I improved it. The problems 
with his program - http://ftp1.sam-hosting.co.il/~omri/benchmarks/prime.pl
was:

1. He used $i = $i + 2 instead of $i +=2.

2. He used $ii <<= int(sqrt($i) as the condition in a for loop. This caused 
int(sqrt()) to be calculated over and over again.

3. He assigned to $prime over and over again in the inner loop. The $prime 
assignment should have been before the inner loop.

4. He did not use "use integer".

I corrected these problems and as a result the program ran much faster.

Regards,

	Shlomi Fish

-- 

---------------------------------------------------------------------
Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

Knuth is not God! It took him two days to build the Roman Empire.



More information about the Perl mailing list