Created
March 26, 2014 19:39
-
-
Save schwern/9791519 to your computer and use it in GitHub Desktop.
5.20 signatures vs Method::Signatures, runtime benchmark
This file contains 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/perl | |
use v5.10; | |
use strict; | |
use warnings; | |
use Benchmark qw(cmpthese); | |
{ | |
package MS; | |
use Method::Signatures; | |
func add($a, $b) { | |
return $a + $b; | |
} | |
func defaults($a = 23, $b = 42) { | |
return $a + $b; | |
} | |
} | |
{ | |
package Builtin; | |
use feature 'signatures'; | |
no warnings 'experimental::signatures'; | |
sub add($a, $b) { | |
return $a + $b; | |
} | |
sub defaults($a = 23, $b = 42) { | |
return $a + $b; | |
} | |
} | |
cmpthese shift, { | |
builtin_add => sub { Builtin::add(1, 2) }, | |
ms_add => sub { MS::add(1,2) }, | |
}; | |
cmpthese shift, { | |
builtin_defaults => sub { Builtin::defaults() }, | |
ms_defaults => sub { MS::defaults() }, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment