It's often hard to find a balance between performance and writing readable code. We all know that it's more efficent to combine multiple "prints" into one statement. Further according to Mastering Algorithms in Perl it is "1.5%" faster to use a "," instead of a "." in combined print statements. But beyond that what else is possible? It is often nessicary to break up data output into different subs or to have logic mixed between statements. So is it more efficent (correct?) to store output in a scalar and then "print" it when your done generating output or to make several prints.
Of course this would be on a much larger scale...
vs.$string .= "someoutput"; $string .= "someotheroutput"; # logic here $string .= "moreoutput"; print $string;
Also how much will performance vary on different platforms and how large a difference will perl's buffering have?print "someoutput", "someotheroutput"; # loging here print "moreoutput";
Cheers,
-Dogma
In reply to Optimizing Output by Dogma
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |