note 123532 added to function.usort
| From: | chris at candm dot org dot uk | Date: | Sat, 19 Jan 2019 01:15:25 +0000 |
| Subject: | note 123532 added to function.usort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210079@lists.php.net to get a copy of this message | ||
In case anyone is interested, comparative timings over 100000000 runs
Based on comparing integers (500 and 501)
Spaceship:4
()?: operator:10
Subtraction:2
Based on comparing floats (500.1 and 501.3) (caveats noted)
Spaceship:5
()?: operator:9
Subtraction:3
Based on comparing strings ("five" and "four")
Spaceship:7
()?: operator:17
(Subtraction obviously not available)
Note: a dummy run was done with an empty loop and the elapsed time for this was subtracted from each
of the above times so that they reflect ONLY the time to do the comparisons. As for significance.
unless you are doing very large numbers of comparisons where spaceships are the order of the day,
the difference is insignificant.
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.142 (proxied: 125.162.135.128)
----
Manual Page -- http://php.net/manual/en/function.usort.php
Edit -- https://master.php.net/note/edit/123532
Del: integrated -- https://master.php.net/note/delete/123532/integrated
Del: useless -- https://master.php.net/note/delete/123532/useless
Del: bad code -- https://master.php.net/note/delete/123532/bad+code
Del: spam -- https://master.php.net/note/delete/123532/spam
Del: non-english -- https://master.php.net/note/delete/123532/non-english
Del: in docs -- https://master.php.net/note/delete/123532/in+docs
Del: other reasons-- https://master.php.net/note/delete/123532
Reject -- https://master.php.net/note/reject/123532
Search -- https://master.php.net/manage/user-notes.php