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

The IO involved in opening/closing/reading/writing those files is probably where you are spending the most of your time in those benchmarks. Since you're doing the same amount of IO in both test, it should affect which one is faster, but it does affect the ratio of sped between the two tests (just like adding a sleep(1) to both makes them both equally sucky)

If you really want to test *only* the CSV time, you can read from a tied filehandle that's really just a string in memory; and write to a tied filehanlde that just throws away the data you write to it.

take a look at Tie::FileHandle::Base the replies to this post as a place to start

  • Comment on Re: Benchmark comparison of Text::xSV and Text::CSV_XS

Replies are listed 'Best First'.
Re^2: Benchmark comparison of Text::xSV and Text::CSV_XS
by dragonchild (Archbishop) on Dec 09, 2004 at 13:58 UTC
    What's wrong with IO::Scalar? I use it in tests all the time ...

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      See, i was certain that module existed ... but i couldn't for the life of me remember what it was called, and my searches didn't turn up anything more promising then the base class.

      -thanx

Re^2: Benchmark comparison of Text::xSV and Text::CSV_XS
by castaway (Parson) on Dec 09, 2004 at 09:01 UTC
    .. Or just open a scalarref, assuming a newish perl (5.8+ I believe) ..
    my $content = ''; open($fh, '<', \$content) ..
    C.

      I'd like to note that the open ..., "<", \ EXPR syntax is a shortcut for open ..., "<:scalar", \ EXPR. I found out once that if you specify any sort of PerlIO layer in the open-type format, you also have to explicitly use the long form otherwise you end up attempting to work with a file named "SCALAR(0x....)" instead of an in-memory file.

      # Ok open ..., "<", \ $content open ..., "<:scalar", \ $content open ..., "<:scalar:crlf", \ $content # Not ok open ..., "<:crlf", \ $content