Skip to content

Instantly share code, notes, and snippets.

@rkitover
Created January 9, 2013 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkitover/4496686 to your computer and use it in GitHub Desktop.
Save rkitover/4496686 to your computer and use it in GitHub Desktop.
#!/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