From 8c9bbd7afd94828da3379c279a5030e9733d5a98 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Tue, 15 Dec 2020 20:28:41 +0100 Subject: [PATCH 1/2] Use native int for counts This appears to fix the strange issue with creating Rats and rounding them. --- lib/CovidObserver/Statistics.rakumod | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/CovidObserver/Statistics.rakumod b/lib/CovidObserver/Statistics.rakumod index 3e3741902..439bdc0d3 100755 --- a/lib/CovidObserver/Statistics.rakumod +++ b/lib/CovidObserver/Statistics.rakumod @@ -1863,10 +1863,10 @@ sub per-capita-data($chartdata, $population-n) is export { for +$chartdata -1 ... 0 -> $index { last unless $confirmed[$index]; - my $c = $confirmed[$index] // 0; - my $f = $failed[$index] // 0; - my $r = $recovered[$index] // 0; - my $a = $active[$index] // 0; + my int $c = $confirmed[$index] // 0; + my int $f = $failed[$index] // 0; + my int $r = $recovered[$index] // 0; + my int $a = $active[$index] // 0; my $date-str = fmtdate($dates[$index]); $date-str ~~ s/^(\w\w\w)\S+/$0/; From 97af65fae5859be59898f217d9569cb4f26dc3d8 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Tue, 15 Dec 2020 20:31:41 +0100 Subject: [PATCH 2/2] generate-(country|continent)-stats in parallel This reduces wallclock of running "generate" from ~33 minutes to about ~11 minutes. --- covid.raku | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/covid.raku b/covid.raku index 970a4bd7d..a5641c237 100755 --- a/covid.raku +++ b/covid.raku @@ -163,10 +163,8 @@ multi sub MAIN('generate', Bool :$skip-excel = False) { generate-china-level-stats(%CO); ## generate-common-start-stats(%countries, %per-day, %totals, %daily-totals); - my %country-stats; - my $known-countries = get-known-countries(); - for @$known-countries -> $cc { - %country-stats{$cc} = generate-country-stats($cc, %CO, :%mortality, :%crude, :$skip-excel); + my %country-stats = get-known-countries<>.race(:1batch,:8degree).map: -> $cc { + $cc => generate-country-stats($cc, %CO, :%mortality, :%crude, :$skip-excel) } generate-countries-compare(%country-stats, %countries, limit => 100); @@ -180,7 +178,7 @@ multi sub MAIN('generate', Bool :$skip-excel = False) { generate-continent-graph(%CO); - for %continents.keys -> $cont { + for %continents.keys.race(:1batch,:8degree) -> $cont { generate-continent-stats($cont, %CO, :$skip-excel); }