-
-
Save AlexDaniel/baae3c4ffda55f9cca783f17aaab1f2b to your computer and use it in GitHub Desktop.
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
#!/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