Created
January 9, 2013 20:34
-
-
Save rkitover/4496686 to your computer and use it in GitHub Desktop.
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/env perl | |
use strict; | |
use warnings; | |
use 5.010; | |
sub base { 1 } | |
package Child; | |
use mro 'c3'; | |
use base 'main'; | |
sub base_super { my $self = shift; $self->SUPER::base(@_); } | |
sub base { my $self = shift; $self->next::method(@_); } | |
package main; | |
use Benchmark; | |
timethese(1_000_000, { | |
'SUPER::' => sub { Child->base_super }, | |
'next::method' => sub { Child->base }, | |
}); | |
__END__ | |
Benchmark: timing 1000000 iterations of SUPER::, next::method... | |
SUPER::: 6 wallclock secs ( 7.24 usr + 0.00 sys = 7.24 CPU) @ 138121.55/s (n=1000000) | |
next::method: 9 wallclock secs ( 9.25 usr + 0.00 sys = 9.25 CPU) @ 108108.11/s (n=1000000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment