go ahead... be a heretic | |
PerlMonks |
RE: RE: Schwartzian Transform vs. plain Perlby mikfire (Deacon) |
on Jun 08, 2000 at 17:50 UTC ( [id://17080]=note: print w/replies, xml ) | Need Help?? |
As long as both functions are doing the hash generation,
my first estimation is that it won't change the relation
between the methods. I could go through lots of mathematical
gyrations, but I won't.
Thinking a bit more about it, the first function to run may get more penalized than the second, depending on how aggressive perl is in reusing memory. The first call to initialize the hash will have to allocate memory from the system. After the my'd hash goes out of scope, the memory is marked as free but perl doesn't give it back to the system. The next time the hash is allocated, perl may ( again, depending on how aggressive perl is ) just give it the same space. This should be faster than trying to malloc the same amount of space. Given 100,000 iterations of each loop I still do not think the penalty is going to be large enough to introduce any skew. Personally, I also try to do that stuff outside of the timing loop - I want to remove as many distractions as possible and make sure I am timing how fast the sort is, not how fast my machine can allocate memory or how effectively perl is reusing it.
In Section
Seekers of Perl Wisdom
|
|