Last active
June 24, 2019 15:17
-
-
Save antoniogamiz/c09b16ee979d991a61c2bdcbf6f1eb4d 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
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