Created
July 1, 2014 09:14
-
-
Save ian-kent/50aa872d2091271d2bf3 to your computer and use it in GitHub Desktop.
Perl subroutine arguments test
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 Time::HiRes qw/ gettimeofday tv_interval /; | |
my $iters = 50000000; | |
package panda { | |
use Mojo::Base -base; | |
my $buf = ""; | |
sub test_shift { | |
my $self = shift; | |
my %args = @_; | |
$buf = $args{foo} . $args{bar}; | |
$buf = ""; | |
} | |
sub test_slurp { | |
my ($self, %args) = @_; | |
$buf = $args{foo} . $args{bar}; | |
$buf = ""; | |
} | |
} | |
my $obj = panda->new; | |
my ($s, $e, $i); | |
{ | |
$s = [gettimeofday]; | |
for (1 .. $iters) { | |
$obj->test_shift(foo => "123", bar => "456"); | |
} | |
$e = [gettimeofday]; | |
$i = tv_interval($s, $e); | |
print "test_shift completed in $i seconds\n"; | |
} | |
{ | |
$s = [gettimeofday]; | |
for (1 .. $iters) { | |
$obj->test_slurp(foo => "123", bar => "456"); | |
} | |
$e = [gettimeofday]; | |
$i = tv_interval($s, $e); | |
print "test_slurp completed in $i seconds\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment