in reply to Question with Benchmark.pm

Why not just write to a dummy file. I kind of like this a hair better than writting to dev null or monkeying around with stdout. This would be a very fast change.

open my $fh, '>','delete.this.later' or die ("Unable to open temp file + : $!"); ... my $result = timethese ( -5, { test => sub { print $fh @A }, ...

And then just delete the file afterword. Sure you'll introduce a bit of Disk IO, but it's the same DiskIO for all of your test threads, so it should wash out in terms of a comparison.

--
I used to drive a Heisenbergmobile, but every time I looked at the speedometer, I got lost.

Replies are listed 'Best First'.
Re^2: Question with Benchmark.pm
by chromatic (Archbishop) on Dec 13, 2007 at 19:13 UTC
    Sure you'll introduce a bit of Disk IO, but it's the same DiskIO for all of your test threads, so it should wash out in terms of a comparison.

    Are you sure? The example data is far less than the size of a buffer, so won't Perl fill up a buffer and only then write it? That pattern will be predictable but it won't be uniform across those files.

    Benchmarking is difficult; IO doubly so.