Just as a data point, I ran this on my workstation. Perl v5.8.7 built for i486-linux-gnu-thread-multi on Debian.
I ran it a bunch of times, with the "undef %testHash1;" in and out. The rate varied from 111,000/sec to 250,000/sec, but never anywhere remotely close to your 9000. So, you may have issues with your particular release or platform, but this does not seem to be common to all installations.
Update:
Doing some quick reading, I checked out recipie 5.13 in Perl Cookbook. It has a sentence that might shed some light: "Perl already shares keys between hashes, so if you already have a hash with "Apple" as a key, Perl won't need to allocate memory for another copy of "Apple" when you had an entry whose key is "Apple" to another hash".
Since both keys are about "PROTEST SONG", I'd be most interested if you'd re-run your benchmarks with an entirely different pattern on your second hash key...
Another Update:
After seeing Ikegami's results on Windows, I decided to try it on an old NT4 box. Perl version is ActiveState build 813 of Perl 5.8.7. With the undef in place, keys per second were 47619 and 66667. Weird.
In reply to Re: Use of undef slowing down perl?
by pboin
in thread Use of undef slowing down perl?
by thalej
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |