in reply to Re: undef speedup ?!
in thread undef speedup ?!
timethese 10000, { this => ' ...... ', that => ' ...... ' };
When benchmarking I'm accustomed to using the sub format, like this:
timethese 10000, { this => sub { ..... }, that => sub { ..... } }
...which follows a more natural lexical scoping, where the subs are still executed within the same scope as the lexical block in which they're called.
For the record, the following code now matches the OP's observed behavior:
use strict; use warnings; use Benchmark; my (%h_delete, %h_list, %h_undef); %h_delete = %h_list = %h_undef = (1 .. 50000); delete @h_delete{keys %h_delete}; %h_list = (); undef %h_undef; timethese 10000, { delete => sub{ 1 for keys %h_delete}, list => sub{ 1 for keys %h_list}, undef => sub{ 1 for keys %h_undef}, };
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: undef speedup ?!
by Abigail-II (Bishop) on Feb 09, 2004 at 17:39 UTC |