-
-
Save timo/7477f7cecfc2a0c5bf8096ac98499740 to your computer and use it in GitHub Desktop.
uninteresting string join benchmark involving \r\n synthetic
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
srand(99); | |
my @chunks = ("hello", "\r"), | |
("goodbye", "\r\n"), | |
("yo", "\t"), | |
("omg", " "); | |
my @collection = |(@chunks.pick) xx 5000; | |
my %results{Any}; | |
my $elems_per_line; | |
for ([\,] @collection).pick(1000) -> $selection { | |
my $start = now; | |
for ^100 { | |
my $ = $selection.join("") | |
} | |
%results{$selection.elems} = (now - $start).Num; | |
print "."; | |
$elems_per_line += $selection.elems; | |
if ++$ %% 50 { | |
say " $elems_per_line"; | |
$elems_per_line = 0; | |
} | |
} | |
say "done"; | |
for %results { | |
say "$_.key() $_.value()"; | |
} | |
# results in pretty much a straight linear line. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment