Just another Perl shrine | |
PerlMonks |
RE: Schwartzian Transform vs. plain Perlby jjhorner (Hermit) |
on Jun 08, 2000 at 16:44 UTC ( [id://17065]=note: print w/replies, xml ) | Need Help?? |
I usually take my variable assignment out of the subroutines. I took the hash generation:
out of the subroutines and here is what I got (I had to up the iterations to 100000!):
Does anyone see any benefit to forcing the hash generation each iteration, or does one declaration work just as well? So, to support your theory, I got roughly the same times. To make sure, I upped it to 1000000 iterations:
I believe, and correct me if I'm wrong, the length of values involved makes it less cpu intensive to do the dereferences and indexing. Perhaps if we tried it on larger key->value pairs, we would see more correct results. The _EPP_ Book where I see the Schwartzian Transform, it also notes that the best part of the Schwartzian Transform "is that it tends to be the fastest way to perform complicated sorts". J. J. Horner Linux, Perl, Apache, Stronghold, Unix jhorner@knoxlug.org http://www.knoxlug.org/
In Section
Seekers of Perl Wisdom
|
|