Created
October 10, 2010 16:13
-
-
Save anonymous/619356 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
use v6; | |
use Benchmark; | |
my $string = "a b c d \n"; | |
my %results = timethese(1000, { | |
"chomp" => sub { $string.chomp }, | |
"chop" => sub { $string.chop if $string.substr(-1) == any("\n", "\r\n") }, | |
"flip" => sub { $string.flip.substr(1).flip if $string.substr(-1) == any("\n", "\r\n") }, | |
"substr" => sub { $string.substr(0,-1) if $string.substr(-1) == any("\n", "\r\n") }, | |
}); | |
say ~%results; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment