Skip to content

Instantly share code, notes, and snippets.

@timo
Created March 20, 2017 16:48
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 timo/7477f7cecfc2a0c5bf8096ac98499740 to your computer and use it in GitHub Desktop.
Save timo/7477f7cecfc2a0c5bf8096ac98499740 to your computer and use it in GitHub Desktop.
uninteresting string join benchmark involving \r\n synthetic
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