Skip to content

Instantly share code, notes, and snippets.

@moritz
Created July 23, 2012 11:08
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 moritz/3163118 to your computer and use it in GitHub Desktop.
Save moritz/3163118 to your computer and use it in GitHub Desktop.
Counting character occurrences
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