Created
November 1, 2009 07:49
-
-
Save gfx/223428 to your computer and use it in GitHub Desktop.
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
#!perl -w | |
use strict; | |
use Benchmark qw(:all); | |
use Sub::Call::Tail; | |
sub foo{ 1 } | |
sub tailcall{ | |
tail foo(1, 2, 3); | |
} | |
sub do_goto{ | |
@_ = (1, 2, 3); | |
goto &foo; | |
} | |
sub normal{ | |
foo(1, 2, 3); | |
} | |
cmpthese -1 => { | |
tail => sub{ | |
tailcall(); | |
}, | |
goto => sub{ | |
do_goto(); | |
}, | |
normal => sub{ | |
normal(); | |
}, | |
}; |
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
$ perl -Mblib benchmark/benchmark.pl | |
Rate goto tail normal | |
goto 562196/s -- -66% -70% | |
tail 1635885/s 191% -- -13% | |
normal 1890462/s 236% 16% -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment