Sigh. Fooled again :)
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] |
Then again, if you eliminate the optimisation advantage;
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark 'cmpthese';
use List::Util 'shuffle';
our @data = shuffle 1 .. 10000;
cmpthese -1, {
'<=>' => q[@s1=sort sub{ $b<=>$a }, @data],
' - ' => q[@s2=sort sub{ $b - $a }, @data],
};
__END__
P:\test>junk
Rate <=> -
<=> 36.9/s -- -2%
- 37.4/s 2% --
P:\test>junk
Rate - <=>
- 36.3/s -- -3%
<=> 37.4/s 3% --
P:\test>junk
Rate - <=>
- 35.8/s -- -0%
<=> 35.8/s 0% --
P:\test>junk
Rate <=> -
<=> 36.8/s -- -0%
- 36.9/s 0% --
... it makes no difference whether the block returns (-1,0,1) or (-n,0,n), which is more relavent to the original discussion.
However, in C or asm, it might avoid an unnecessary booleanisation of a subtraction?
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] |