Created
February 4, 2015 08:22
-
-
Save Tux/6520a23f118908ae8237 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
#!perl6 | |
use v6; | |
use Slang::Tuxic; | |
use Inline::Perl5; | |
my $p5 = Inline::Perl5.new; | |
$p5.use ("Text::CSV_XS"); | |
my @rows; | |
my $csv = $p5.invoke ("Text::CSV_XS", "new") | |
or die "Cannot use CSV: ", $p5.invoke ("Text::CSV", "error_diag"); | |
$csv.binary (1); | |
$csv.auto_diag (1); | |
my Int $sum = 0; | |
for lines () :eager { | |
$csv.parse ($_); | |
$sum += $csv.fields.elems; | |
} | |
$sum.say; | |
=> | |
csv-easy-xs 50000 0.021 | |
csv-easy-pp 50000 0.019 | |
csv-test-xs 50000 0.039 | |
csv-test-pp 50000 0.520 | |
csv-pegex 50000 1.371 | |
csv 50000 8.268 | |
csv-ip5xs 50000 9.257 <=== | |
csv_gram *** 60000 13.843 | |
test 50000 40.042 | |
test-x 50000 42.783 | |
What I really would like to see is (pseudo-syntax) | |
my Int $sum = 0; | |
while (my $row = $csv.getline (*ARGV)) { | |
$sum += +(@$row); | |
} | |
$sum.say; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment