in reply to Benchmarking Simple Perl program vs. Java equivalent
You can optimize your code a little bit by transforming the C-like for( my $i = 0 ; $i < 50 ; $i++ ) into for(0..50) and keys %{$simulation_h} into an array outside the for loops with all that I've reduced execution time 17% ( aprox ~ 3.5 secs ).
In general the more you try to optimize your code the uglier and less maintainable it will be. On the other hand usually strong typed languages like C/Java can be optimized more than weak typed ones.
You choose Perl not because its faster than Java or C you choose it because your productivity gets boosted in Perl and you can come up real quick with working prototypes or you use the flexibility it gives you.
If execution speed is the only thing you care about then:
I'd recommend you to read High Performance Perl it is an interesting thread
|
|---|