note 106082 deleted from function.abs by hholzgra
| From: | hholzgra@php.net | Date: | Sun, 15 Apr 2012 19:32:00 +0000 |
| Subject: | note 106082 deleted from function.abs by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187152@lists.php.net to get a copy of this message | ||
Note Submitter: Tig
----
If doing a single conversion to ">= 0" on a random input, in order to workout the value
of the input (corrected to 0 or greater), the quickest method is:
$x = abs($input);
After a bit more testing and thinking about how the test page (in the post below) works, it appears
the results are correct, but _only_ when looping over the different methods for a lot of loops. For
a single test or correction, the results are wrong.
The results for option 1 and 3 are very close to each other, but option 2 is clearly the quickest of
the three.
After removing the loops, the results where:
1) Result [938]: 1.5974044799805E-5 sec.
2) Result [938]: 5.9604644775391E-6 sec.
3) Result [938]: 1.5020370483398E-5 sec.
(note the E-5 and E-6 at the end)