note 72626 added to function.min
| From: | ahigerd at stratitec dot com | Date: | Fri, 26 Jan 2007 16:44:19 +0000 |
| Subject: | note 72626 added to function.min | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122235@lists.php.net to get a copy of this message | ||
nonick AT 8027 DOT org commented that min() is slower than using the ternary operator, but if
you've researched performance of the ternary operator in PHP before, you'll actually know
that you can go a step faster: (these tests are on 1,000,000 iterations)
$a = min($b, $c); // 0.837 sec
$a = ($b < $c) ? $b : $c; // 0.411 sec
if($b < $c) $a = $b; else $a = $c; // 0.374 sec
PHP exhibits the strange behavior that shorter code often performs SLOWER than longer code.
----
Server IP: 69.147.83.197
Probable Submitter: 75.19.79.5
----
Manual Page -- http://www.php.net/manual/en/function.min.php
Edit -- https://master.php.net/note/edit/72626
Del: integrated -- https://master.php.net/note/delete/72626/integrated
Del: useless -- https://master.php.net/note/delete/72626/useless
Del: bad code -- https://master.php.net/note/delete/72626/bad+code
Del: spam -- https://master.php.net/note/delete/72626/spam
Del: non-english -- https://master.php.net/note/delete/72626/non-english
Del: in docs -- https://master.php.net/note/delete/72626/in+docs
Del: other reasons-- https://master.php.net/note/delete/72626
Reject -- https://master.php.net/note/reject/72626
Search -- https://master.php.net/manage/user-notes.php