Skip to content

Commit 05ad94c

Browse files
author
H.Merijn Brand - Tux
committed
Add competitors for comparison
1 parent 43d3a63 commit 05ad94c

File tree

6 files changed

+90
-0
lines changed

6 files changed

+90
-0
lines changed

README

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sh$ for i in $(seq 1 1000000); do echo 'hello,","," ",world,"!"'; done > /tmp/hello.csv
2+
sh$ time perl csv.pl < /tmp/hello.csv
3+
4+
Text::CSV_XS 0.038
5+
Text::CSV_PP 0.651
6+
Text::CSV::Easy_XS 0.022
7+
Text::CSV::Easy_PP 0.018
8+
Pegex::CSV 1.947
9+
csv.pl 12.543
10+
test.pl 256.985
11+
12+
time perl csv-easy-pp.pl < /tmp/hello.csv
13+
time perl csv-easy-xs.pl < /tmp/hello.csv
14+
time perl csv-test-pp.pl < /tmp/hello.csv
15+
time perl csv-test-xs.pl < /tmp/hello.csv
16+
time perl csv-pegex.pl < /tmp/hello.csv
17+
time perl6 csv.pl < /tmp/hello.csv
18+
time perl6 test.pl < /tmp/hello.csv
19+

csv-easy-pp.pl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
6+
use Text::CSV::Easy_XS qw(csv_parse);
7+
8+
my $sum = 0;
9+
while (my $line = <>) {
10+
my @row = csv_parse ($line);
11+
$sum += @row;
12+
}
13+
print "$sum\n";

csv-easy-xs.pl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
6+
use Text::CSV::Easy_XS qw(csv_parse);
7+
8+
my $sum = 0;
9+
while (my $line = <>) {
10+
my @row = csv_parse ($line);
11+
$sum += @row;
12+
}
13+
print "$sum\n";

csv-pegex.pl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/pro/bin/perl
2+
3+
use 5.16.2;
4+
use warnings;
5+
6+
use Pegex::CSV;
7+
8+
local $/;
9+
my $sum = 0;
10+
for (@{Pegex::CSV->load (<>)}) {
11+
$sum += scalar @$_;
12+
}
13+
say $sum;

csv-test-pp.pl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
6+
use Text::CSV_PP;
7+
8+
my @rows;
9+
my $csv = Text::CSV_PP->new ({ binary => 1, auto_diag => 1 } )
10+
or die "Cannot use CSV: ", Text::CSV->error_diag ();
11+
12+
my $sum = 0;
13+
while (my $row = $csv->getline (*ARGV)) {
14+
$sum += scalar @$row;
15+
}
16+
print "$sum\n";

csv-test-xs.pl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
6+
use Text::CSV_XS;
7+
8+
my @rows;
9+
my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 } )
10+
or die "Cannot use CSV: ", Text::CSV->error_diag ();
11+
12+
my $sum = 0;
13+
while (my $row = $csv->getline (*ARGV)) {
14+
$sum += scalar @$row;
15+
}
16+
print "$sum\n";

0 commit comments

Comments
 (0)