Created
May 1, 2015 16:30
-
-
Save sestaton/f63e7af47d63b8107975 to your computer and use it in GitHub Desktop.
benchmark sting formatting
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
#!/usr/bin/env perl | |
use 5.020; | |
use strict; | |
use warnings; | |
use Benchmark qw(:all); | |
my $seq = "ATCG" x 25e6; # 100Mb string | |
my $count = 10; | |
my $results = timethese($count, { | |
'regex' => sub { | |
$seq =~ s/(.{60})/$1\n/gs; | |
say STDERR $seq; | |
}, | |
'unpack' => sub { | |
say STDERR $_ for unpack("(A60)*", $seq); | |
}, | |
}); | |
cmpthese( $results ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment