Created
August 17, 2011 14:42
-
-
Save sugar84/1151648 to your computer and use it in GitHub Desktop.
params to hash vs params to hash_ref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use Benchmark qw/cmpthese/; | |
| sub hash { | |
| my $self = shift; | |
| my %params = @_; | |
| return; | |
| } | |
| sub hash_ref { | |
| my $self = shift; | |
| my $params = {@_}; | |
| return; | |
| } | |
| cmpthese(-2, { | |
| hash => sub { hash( "self", first => 1, second => 2, third => 3) }, | |
| hash_ref => sub { hash_ref("self", first => 1, second => 2, third => 3) }, | |
| }); | |
| __END__ | |
| perl 5.12.3: | |
| Rate hash hash_ref | |
| hash 198194/s -- -24% | |
| hash_ref 261897/s 32% -- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment