Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Last active March 28, 2018 00:22
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 AlexDaniel/baae3c4ffda55f9cca783f17aaab1f2b to your computer and use it in GitHub Desktop.
Save AlexDaniel/baae3c4ffda55f9cca783f17aaab1f2b to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
my str $str = 'abcdefgh' ~ 'efghefgh';
my $imax = 1024 / $str.codes * 1024 * 4; # 4mb
my $starttime = now;
say "exec.tm.sec\tstr.length";
my str $gstr='';
my $i=0;
while ($i++ < $imax + 1000) { #adding 1000 iterations to delay exit. This will allow to capture memory usage on last step
$gstr ~= $str;
$gstr ~~ s:g/efgh/____/;
my $lngth = $str.codes * $i;
say round(now - $starttime), "sec\t\t", $lngth/1024, 'kb' if $lngth %% (1024 * 256); #print out every 256kb
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment