EvdB has asked for the wisdom of the Perl Monks concerning the following question:
I recently ran Benchmark on some of my code and am curious as to how best to look at the results.
In the follwing code $link is an object which can be loaded from the database or the cache using the two private functions benchmarked and $criteria is a hashhref.
Update:
use Benchmark qw(cmpthese);
cmpthese( 10_000,
{
'From Cache' => sub{ $link->_load_from_database( $criteria ); },
' From DBI' => sub{ $link->_load_from_cache ( $criteria ); }
}
);
The results of the benchmarking are:use Benchmark qw(cmpthese); cmpthese( 10_000, { 'From Cache' => sub{ $link->_load_from_cache ( $criteria ); } +, ' From DBI' => sub{ $link->_load_from_database( $criteria ); } } );
As you can see the Cache code is much faster at 1314/sec (DBI is 660/sec). However the wall clock times for both are the same, and as 10_000 iterations were timed this would imply that in user time there is not much to choose between them.Benchmark: timing 10000 iterations of From DBI, From Cache... From DBI: 16 wallclock secs (13.66 usr + 1.50 sys = 15.16 CPU) @ 65 +9.63/s (n=10000) From Cache: 16 wallclock secs ( 6.86 usr + 0.75 sys = 7.61 CPU) @ 13 +14.06/s (n=10000) Rate From DBI From Cache From DBI 660/s -- -50% From Cache 1314/s 99% --
My question is "how should I look at these results?". What generally accounts for time that Benchmark does not see, and which time result should I use in making performance questions. I hope that this is enough detail for a general discussion as opposed to specifically looking at the code I posted.
-- tidiness is the memory loss of environmental mnemonics
Update per author - dvergin 2003-02-12
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interpreting Benchmark results. (oops)
by tye (Sage) on Feb 12, 2003 at 15:27 UTC | |
by EvdB (Deacon) on Feb 12, 2003 at 18:46 UTC | |
|
Re: Interpreting Benchmark results.
by l2kashe (Deacon) on Feb 12, 2003 at 16:23 UTC | |
|
Re: Interpreting Benchmark results.
by jasonk (Parson) on Feb 12, 2003 at 15:04 UTC | |
|
Re: Interpreting Benchmark results.
by hossman (Prior) on Feb 13, 2003 at 02:12 UTC | |
|
Re: Interpreting Benchmark results.
by !unlike (Beadle) on Feb 12, 2003 at 15:34 UTC |