in reply to Benchmark.pm: Does subroutine testing order bias results?
I think that your right in that under some circumstances, Benchmark seems to consistantly favor the first test run. If the code under test does a lot of allocation and deallocation, as I suspect (but don't know) that List::Compare does? Then the first test seems to run substantially quicker. The subsequent tests seem to get a fairly even performance.
Here, the code tested is identical in all cases, but the first test run (Atest), consistantly comes out 23%-46% faster than the other (identical?) tests.
#! perl -slw use strict; use Benchmark qw[ cmpthese ]; sub test { my @strings = map{ ' ' x 1000 } 1 .. 50_000; } cmpthese( 5, { Atest => \&test, Btest => \&test, Ctest => \&test, Dtest => \&test, }); __END__ s/iter Ctest Btest Dtest Atest Ctest 9.29 -- -0% -0% -31% Btest 9.29 0% -- -0% -31% Dtest 9.28 0% 0% -- -31% Atest 6.36 46% 46% 46% -- P:\test>373536-2 s/iter Btest Dtest Ctest Atest Btest 9.31 -- -0% -0% -19% Dtest 9.29 0% -- 0% -19% Ctest 9.29 0% 0% -- -19% Atest 7.54 23% 23% 23% -- s/iter Ctest Btest Dtest Atest Ctest 9.29 -- -0% -0% -31% Btest 9.29 0% -- -0% -31% Dtest 9.28 0% 0% -- -31% Atest 6.36 46% 46% 46% -- P:\test>373536-2 s/iter Btest Dtest Ctest Atest Btest 9.31 -- -0% -0% -19% Dtest 9.29 0% -- 0% -19% Ctest 9.29 0% 0% -- -19% Atest 7.54 23% 23% 23% --
I have a tentative conclusion for why this might be, but the size of the difference shown by the benchmark seems too big for my thought to explain all of it. So, I'll keep my trap shut for a while and see what others think.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Benchmark.pm: Does subroutine testing order bias results?
by hossman (Prior) on Jul 15, 2004 at 03:58 UTC | |
by BrowserUk (Patriarch) on Jul 15, 2004 at 05:17 UTC | |
|
Re^2: Benchmark.pm: Does subroutine testing order bias results?
by Anonymous Monk on Jul 18, 2004 at 13:55 UTC | |
|
Re^2: Benchmark.pm: Does subroutine testing order bias results?
by jkeenan1 (Deacon) on Jul 18, 2004 at 14:10 UTC | |
by BrowserUk (Patriarch) on Jul 18, 2004 at 16:07 UTC | |
by jkeenan1 (Deacon) on Jul 18, 2004 at 17:13 UTC | |
by BrowserUk (Patriarch) on Jul 18, 2004 at 17:40 UTC | |
by jkeenan1 (Deacon) on Jul 19, 2004 at 21:30 UTC |