in reply to Benchmark comparison of Text::xSV and Text::CSV_XS

Because the original issue was one of the Windows version of CSV_XS, I have composed a Benchmark similar to my orignal. This covers reading only, and uses the ASPN version of CSV_XS (as opposed to compiling it myself):

#!/usr/bin/perl use strict; use warnings; use Benchmark qw(:all); my @buffer; cmpthese( 200, { 'xSV' => \&xSV, 'CSV' => \&CSV_XS } ); sub xSV { print STDERR '.'; use Text::xSV; my $xsv = new Text::xSV(filename=>"sample.csv", sep=>';'); while (my $row = $xsv->get_row) { @buffer = @$row; #just a "do something" instruction } undef @buffer; print STDERR '.'; } sub CSV_XS { print STDERR '*'; use Text::CSV_XS; use IO::File; my $io = new IO::File "< sample.csv"; my $csv = new Text::CSV_XS({sep_char=>';'}); while (my $row = $csv->getline($io)) { last unless @$row; @buffer = @$row; #just a "do something" instruction } undef @buffer; $io->close; print STDERR '*'; }
Results for three runs (I've trimmed the status indicators):
  1.       Rate  xSV  CSV
    xSV 2.11/s   -- -75%
    CSV 8.51/s 304%   --
    
  2.       Rate  xSV  CSV
    xSV 2.20/s   -- -74%
    CSV 8.52/s 287%   --
    
  3.       Rate  xSV  CSV
    xSV 2.19/s   -- -74%
    CSV 8.40/s 284%   --
    
As you can see, Text::CSV_XS is noticably faster than Text::xSV, though the margins are not as large as on my Linux machines. I'm glad that someone pointed out that CSV_XS is now available through ASPN, as it allows me to write fast, portable CSV-handling code now. ;-)

I guess I don't know how to optimize a compiler for Windows... but I knew that already.

radiantmatrix
require General::Disclaimer;
s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}

  • Comment on Benchmark comparison of Text::xSV and Text::CSV_XS (New for Windows)
  • Download Code