Bash, PHP or Perl?
One thing that is for certain is that some people like performance. Running an operating system like Linux gives you choices right out of the box for scripting. This blog post will show the differences in times between Bash, PHP and Perl.
Basically what I have done is created three scripts, one in each language. Then I run them with the time tool to test out the execution time.
Here are the results of echoing 1-100000 out to /dev/null for each script:
BASH: real 0m1.966s user 0m1.664s sys 0m0.072s PHP: real 0m0.309s user 0m0.220s sys 0m0.048s Perl: real 0m0.126s user 0m0.096s sys 0m0.000s |
You can clearly see out of this the order of performance by this test is Perl, PHP and then BASH. Now, what is interesting is when I run the script to stdout these are the results:
BASH: real 0m8.689s user 0m2.408s sys 0m0.416s PHP: real 0m4.381s user 0m0.544s sys 0m0.372s Perl: real 0m3.938s user 0m0.244s sys 0m0.324s |
Bash takes about twice as long as Perl / PHP to complete the exact same task. The winner of this test is Perl but I’ll be doing more tests over time when I become more familiar with Perl