Perl Monk, Perl Meditation | |
PerlMonks |
Re: "exists $hash{key}" is slower than "$hash{key}"by choroba (Cardinal) |
on Jan 06, 2020 at 01:01 UTC ( [id://11111018]=note: print w/replies, xml ) | Need Help?? |
Unfortunately, you can't access the lexical hash variable from a string-evaled code in Benchmark, so the benchmarks measures nothing.
5.26.1 on Linux: Blead gives smaller differences, but the order is the same. Update: Changing q{ to sub { changes the order randomly and makes the difference less than 10%. Update 2: Changing 1001 to 2001 in the benchmarked code (i.e. testing non-existent key) changes the differences to 20% and less, e.g.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Meditations
|
|