in reply to Re: alternatives to if and series of elsif
in thread alternatives to if and series of elsif
Like your foreach method.
Btw, if the sub is called a lot, would it be faster to have the values hard-coded into @comparisons rather than have them generated using map?
Added: I think you mistyped (i.e. missing ->):
if $points > $cmp[0] && $quota < $cmp[1] Should be: if $points > $cmp->[0] && $quota < $cmp->[1]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: alternatives to if and series of elsif
by gsiems (Deacon) on Jul 02, 2005 at 03:40 UTC | |
Rate davidrw_1 op_orig ternary davidrw_2 op_cmp2
davidrw_1 22411/s -- -86% -86% -87% -90%
op_orig 162293/s 624% -- -1% -4% -29%
ternary 163840/s 631% 1% -- -3% -28%
davidrw_2 169239/s 655% 4% 3% -- -26%
op_cmp2 227555/s 915% 40% 39% 34% --
Update: Added kutsu's suggestion to the mix:
Rate kutsu davidrw_1 op_orig ternary davidrw_2 op_cmp2
kutsu 15170/s -- -31% -90% -91% -91% -93%
davidrw_1 21976/s 45% -- -86% -86% -87% -90%
op_orig 159288/s 950% 625% -- -1% -9% -31%
ternary 160777/s 960% 632% 1% -- -8% -30%
davidrw_2 174121/s 1048% 692% 9% 8% -- -24%
op_cmp2 229681/s 1414% 945% 44% 43% 32% --
| [reply] [d/l] |
by kiat (Vicar) on Jul 02, 2005 at 03:49 UTC | |
Me need to go figure what what 15170/s means... | [reply] |
by gsiems (Deacon) on Jul 02, 2005 at 04:04 UTC | |
| [reply] |
by kiat (Vicar) on Jul 02, 2005 at 04:08 UTC | |
by gsiems (Deacon) on Jul 02, 2005 at 04:11 UTC | |
| |
by kiat (Vicar) on Jul 02, 2005 at 11:45 UTC | |
Note that I changed the map code to: That is, 16 .. 24 instead of 24 .. 16. | [reply] [d/l] [select] |
by gsiems (Deacon) on Jul 03, 2005 at 03:14 UTC | |
Test data: pts qt result ----- -- ------ 6906 23 15 12199 22 15 17402 17 23 3470 19 15 16603 19 23 17962 23 15 15762 23 15 6115 23 15 16711 16 23 1936 21 15 870 21 15 1338 23 15 10537 22 15 14295 18 22 11041 19 20 15167 21 22 16712 17 23 10767 18 20 14383 22 15 485 20 15 9298 18 19 7096 19 15 10030 17 20 11104 20 15 12730 22 15 op_cmp2 failed on 6906, 23: returned 18. davidrw_1 looks ok davidrw_2 failed on 17402, 17: returned 15. davidrw_2_5 failed on 17402, 17: returned 18. ternary_cmp looks ok kutsu failed on 17402, 17: no value returned. | [reply] [d/l] |
by kiat (Vicar) on Jul 03, 2005 at 11:11 UTC | |