+ 3

python and perl timing on the same task

Hi Everyone, I wrote perfect number search programs in both perl and python. I used the algorithm for factoring and perfect checking routines in both languages. I ran both the python and perl code on my old Mac G4 powerbook. the version of perl was v5.8.x and the python version 2.3.x . The perl code ran in approximately 5sec, and the python code ran for about 90sec. that means perl is 18 times faster than Python when finding perfect numbers. Why is the run times so different???

8th Apr 2018, 6:53 AM
Rick Shiffman
Rick Shiffman - avatar
4 odpowiedzi
+ 3
Hi , here's a url to my python versions of a perfect number program... https://code.sololearn.com/cxeS76npl72Y/?ref=app
8th Apr 2018, 7:24 PM
Rick Shiffman
Rick Shiffman - avatar
+ 2
Hello everyone. I reran my timing Tests between Perl and Python, but this time on a different machine in my laptop. Both the pearl and the python program define perfect numbers ran within one second of each other. I ran the range from 1 to 9000 and parole rent for 13 seconds by thunder in for 14 seconds
11th Apr 2018, 5:51 PM
Rick Shiffman
Rick Shiffman - avatar
+ 2
It looks like my old Mac PowerBook has an incredibly old and slow version of Python where the Perl 5.8 runs much better on my old machine only.
11th Apr 2018, 5:54 PM
Rick Shiffman
Rick Shiffman - avatar
+ 1
Not enough information to go on. I found this though by Googling: "Every new release is a little bit faster but overall Python is steadily 15x slower than C++. Perl has the same trend as Python and is steadily 22x slower than C++" https://blog.famzah.net/2016/02/09/cpp-vs-python-vs-perl-vs-php-performance-benchmark-2016/ This suggests Perl is ordinarily 50% slower tush Python, but then that's a general measurement. Perl might be faster at different things.
8th Apr 2018, 10:33 AM
Emma