![]() |
|
Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^4: 2*pi*$r -- constant function without prototypeby mscharrer (Hermit) |
on May 01, 2008 at 21:30 UTC ( #684006=note: print w/replies, xml ) | Need Help?? |
The benchmark results vary quite much on my laptop (Perl 5.8.8, Ubuntu). Especially 'constant' and 'direct' are not identical but differ by a factor of 1/2 to 2. I had the idea to use Data::Dumper with Deparse = 1 on the hash to look how perl optimizes the constants: (I removed the use warnings; use strict 'refs'; from each sub to make it easier to read). As you can see 'constant' is identical with 'direct' after compilation. 'constant2' still has the dereferencing and referencing included, which makes it slow. The others have the variable included and only differ on how it is accessed. Because Readonly is tied it is the slowest.
In Section
Meditations
|
|