Skip to content

Instantly share code, notes, and snippets.

@yusukebe
Created February 4, 2020 13:44
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 yusukebe/9a695d74d0688236db1b434f2b8a082b to your computer and use it in GitHub Desktop.
Save yusukebe/9a695d74d0688236db1b434f2b8a082b to your computer and use it in GitHub Desktop.
use Text::CSV;
# 最初にまるごとメモリに読み込んでる。改善できるところ
my @a = csv(in => "caribbean.csv");
await do for @a -> @line {
start {
parse(@line);
}
}
# do for @a -> @line {
# parse(@line);
# }
sub parse(@line) {
sleep 10 / 1000; # 時間のかかる処理をさせる(CSVパース関係なくなってて意味ないけど...)
say @line[3];
}
# 結果
# 同期↓
# raku csv.raku 4.30s user 0.43s system 4% cpu 1:49.63 total
# 非同期↓
# raku csv.raku 4.79s user 0.52s system 29% cpu 17.937 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment