Have you ever wondered how much difference Perl coding styles make to performance? Perl has lots of ways to do the same thing, and some are more readable/maintainable, but are slower or consume more memory...or is it the other way around?
We'll look at Perl syntax and see what performs better or worse and why. Maybe your favorite syntax is an awesome efficient race horse, maybe it's a pig, or maybe it makes no difference. Come see your dreams shattered, hopes dashed, or realize how awesome your syntax choices really are!
14. Copyright 2017 Daina Pettit
Perl Optimization Tidbits – slide 14
Case 1: Auto Increment/Decrement—Results
Pre/post increment/decrement integers and strings
Alphabetic post-increment is twice as slow as numeric!
$x++
++$x – Numeric preincrement faster by 3.7%
$x
$x – Numeric predecrement faster by 2.2%
$str++ – Alphabetic postincrement twice as
fast as preincrement
++$str
16. Copyright 2017 Daina Pettit
Perl Optimization Tidbits – slide 16
Case 2: /xms or not—Results
$x++
++$x – Numeric preincrement faster by 3.7%
$x
$x – Numeric predecrement faster by 2.2%
$str++ – Alphabetic postincrement twice as
fast as preincrement
++$str
m/.../xms – 3% slower and more confusing
m/.../
Do not recommend.