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:
- Buy a faster machine
- Buy several machines and divide the work among them
- Transform your program to a multi-process program to take advantage of multiple processors or idle time when accessing a shared resource
- Start programming in C/Java
I'd recommend you to read High Performance Perl it is an interesting thread
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.