On Sat, Mar 12, 2005 at 11:02:45PM +0000, Mark Stosberg wrote:
> My solution?
>
> my $out = `time $bin diff 1/1 2>&1`;
>
> # XXX Parsing of time output may be fragile
> $out =~ m/\s*([\d\.]*\s+real.*)/;
>
> Ouch.
>
> Perhaps my whole approach is wrong. Am I overlooking a good open source
> tool to benchmark binaries with?
>
> What better ways are there to benchmark system calls from Perl?
Well, if you're just going to look at the wall clock, why use the shell?
my $start_time = time;
`$bin diff 1/1 2>&1`;
my $end_time = time;
my $time = $end_time - $start_time;
If you throw Time::HiRes in there you can get fractional second granularity.
There is also a benchmarking module cunningly named "Benchmark" which you
should have a look at.