in reply to Re: When the Best Solution Isn't
in thread When the Best Solution Isn't
Mindboggling. "qshuf", an N log N algorithm, shows to be 67 faster than any of linear algorithms, and you don't raise a flag?sub qshuf { sort { .5 <=> rand(1) } @_; } cmpthese(10, { slice => sub { slice @array }, xform => sub { xform @array }, shufl => sub { shufl @array }, qshuf => sub { qshuf @array }, }); Rate xform slice shufl qshuf xform 14.4/s -- -38% -70% -100% slice 23.3/s 61% -- -51% -99% shufl 47.8/s 232% 105% -- -99% qshuf 3284/s 22681% 14008% 6767% --
Your benchmark is extremely flawed. You're running your sort in void context. Perl, being smart, knows that sort in void context isn't going to do anything useful, so it's not going to work up a sweat, and just won't do anything.
Benchmark: timing 10000 iterations of qshuf, shufl, slice, xformHmmm, with a first argument of '10' to 'cmpthese'? Either your output doesn't match your program, or your Benchmark.pm module is different than mine.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: When the Best Solution Isn't
by BrowserUk (Patriarch) on Apr 01, 2005 at 10:28 UTC | |
by Anonymous Monk on Apr 01, 2005 at 11:58 UTC | |
by BrowserUk (Patriarch) on Apr 01, 2005 at 12:02 UTC |
In Section
Meditations