I have not benchmarked Text::xSV, but not only is it in pure Perl, but it was not written with an eye to efficiency. This is pointed out in the bugs section, as is the fact that its performance will get drastically worse if you ever use $`, $& or $'.

Given that, I'd be very pleased if it was only 3 times slower than the XS version. However I doubt that I perform that well.

First of all to improve the performance, your read_xSV would be more efficient if you used the fact that get_row() returns the row in array context, so you don't have to call extract. I encourage using the extract method because working "by name" tends to be less buggy than working "by position". OTOH since I'm encouraging people to use extract, you've written it in the way that most people would hopefully write that.

And your benchmark should be rewritten with the error-checks commented out. I guarantee that those checks are taking a non-trivial fraction of the overall time. If you remove them, then I'd bet that the C version does a lot better still than the pure Perl version.

UPDATE: Removed a redundant "is encouraged". Thanks, radiantmatrix.


In reply to Re: Benchmark comparison of Text::xSV and Text::CSV_XS by tilly
in thread Benchmark comparison of Text::xSV and Text::CSV_XS by jZed

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.