Created
July 23, 2012 11:08
-
-
Save moritz/3163118 to your computer and use it in GitHub Desktop.
Counting character occurrences
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 5.010; | |
use Benchmark qw/timethis/; | |
use File::Slurp qw/slurp/; | |
my $input = slurp('p6/rakudo/README') x 100; | |
timethis(20, sub { | |
my %h; | |
$h{$_}++ for split //, $input; | |
return %h; | |
}); | |
__END__ | |
timethis 20: 3 wallclock secs ( 2.73 usr + 0.03 sys = 2.76 CPU) @ 7.25/s (n=20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment