Skip to content

Instantly share code, notes, and snippets.

@sestaton
Created May 1, 2015 16:30
Show Gist options
  • Save sestaton/f63e7af47d63b8107975 to your computer and use it in GitHub Desktop.
Save sestaton/f63e7af47d63b8107975 to your computer and use it in GitHub Desktop.
benchmark sting formatting
#!/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