Skip to content

Instantly share code, notes, and snippets.

@antoniogamiz
Last active June 24, 2019 15:17
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 antoniogamiz/c09b16ee979d991a61c2bdcbf6f1eb4d to your computer and use it in GitHub Desktop.
Save antoniogamiz/c09b16ee979d991a61c2bdcbf6f1eb4d to your computer and use it in GitHub Desktop.
use v6.c;
use Pod::Load;
sub recursive-dir($dir) is export {
my @todo = $dir;
gather while @todo {
my $d = @todo.shift;
for dir($d) -> $f {
if $f.f {
take $f;
}
else {
@todo.append: $f.path;
}
}
}
}
sub read-dir($dir) {
recursive-dir("doc/$dir/")
.grep({.path ~~ / '.pod6' $/})
.map({
.path.subst("doc/$dir/", '')
.subst(rx{\.pod6$}, '')
.subst(:g, '/', '::')
=> $_
});
}
sub MAIN {
my @files = [read-dir($_).Slip for <Type Programs Native Language>];
# secuencial
my $start = now;
for @files {
load($_.value);
}
my $end = now;
my $elapsed = ($end - $start );
say "Secuencial => $elapsed";
# parallel
$start = now;
@files.race(batch => 1).map({ load($_.value) });
$end = now;
$elapsed = ($end - $start );
say "Parallel => $elapsed";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment