in reply to Re: Re: is 'my' that much faster than 'local'?
in thread is 'my' that much faster than 'local'?
So it appears that local can introduce significant overhead into a program even when the program only declares variables a few times but accesses them over and over.Sure. Global variables must be looked up in the symbol table. This is essentially a hash lookup. Lexical variables are retrieved from the scratchpad, which is an array. Arrays are always going to beat hashes for speed.
But I still think my main point is correct: It doesn't matter which one is faster, because they do different things. You use local when it is appropriate, and my when you need my, not because it is faster.
Comparing them for speed doesn't make sense. What would you think if someone asked you whether open was faster or slower than getprotoent? You can write all the benchmarks you want to compare open with getprotoent, and none of them are going to mean a thing.
|
---|