Anjanesh

Assignment Statements, Comparisons & Observations
Font: Size: + -

PHP vs Python vs JavaScript

Friday, April 03, 2020
I was writing code to solve a particular problem on leetcode.com in PHP 7.4 and found that it was taking a lot of time to execute. 10 seconds. Then ported the same code in Python3 thinking it'll be much faster. Nope. 20 seconds. Then I tried JavaScript running not in the browser but in node. Quarter of a second !

Same code in three different languages - three nested loops.

$ time php contiguous-subarray.php
1378

real    0m10.180s
user    0m10.152s
sys 0m0.018s

$ time python3 contiguous-subarray.py
1378

real    0m20.704s
user    0m20.676s
sys 0m0.017s

time node contiguous-subarray.js 
1378

real    0m0.225s
user    0m0.213s
sys 0m0.010s

JavaScript wins.

3 comments:

Packers Movers Chennai said...

Packers and Movers Chennai Give Safe and Reliable ***Household Shifting Services in Chennai with Reasonable ###Packers and Movers Price Quotation. We Provide Household Shifting, Office Relocation, ✔ ✔ ✔ Local and Domestic Transportation Services, Affordable and Reliable Shifting Service Charges @ Packers And Movers Chennai


Packers Movers Jaipur said...

Get Packers and Movers Jaipur List of Top Reliable, 100% Affordable, Verified and Secured Service Provider. Get Free ###Packers and Movers Jaipur Price Quotation instantly and Save Cost and Time. Packers and Movers Jaipur ✔ ✔ ✔ Reviews and Compare Charges for household Shifting, Home/Office Relocation, ***Car Transportation, Pet Relocation, Bike SHifting @ Packers And Movers Jaipur


Packers and Movers Bhubaneswar said...

Get Packers and Movers Bhubaneswar List of Top Reliable, 100% Affordable, Verified and Secured Service Provider. Get Free ###Packers and Movers Bhubaneswar Price Quotation instantly and Save Cost and Time. ✔✔✔Packers and Movers Bhubaneswar Reviews and Compare Charges for household Shifting, Home/Office Relocation, ***Car Transportation, Pet Relocation, Bike SHifting @ Packers And Movers Bhubaneswar