You've rediscovered that moving around code is one way to optimize! I can imagine an optimizer that would take advantage of this, automatically permuting code to find more efficient variations. This is something like the approach used by ATLAS (Automatically Tuned Linear Algebra Software).
ATLAS is smart about not trusting something like the Benchmark module. I think it measures the results with a wall clock and will not compile if the system is otherwise busy. It takes a while to build.
This type of optimization is probably not a desirable way to mangle your perl source code except for fun, but it might be a great technique for optimizing something important like a regular expression engine. Of course it would not just move code around, the optimizer would explore the space of different buffer sizes, etc.
You can find ATLAS at http://math-atlas.sourceforge.net. I have used ATLAS in my projects and it worked great!
It should work perfectly the first time! - toma
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] |