note 99216 deleted from language.operators.comparison by crell

From: Date: Thu, 31 Mar 2022 17:47:52 +0000
Subject: note 99216 deleted from language.operators.comparison by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217880@lists.php.net to get a copy of this message
Note Submitter: mail at markuszeller dot com ---- I prefer writing (!$a == 'hello') much more than ($a != 'hello'), but I wondered about the performance. So I did a benchmark: <?php for($bench = 0; $bench < 3; $bench++) { $start = microtime(true); $a = 1; for($i = 0; $i < 100000000; $i++) { if(!$a == 'hello') $b++; } $end = microtime(true); echo "Used time: " . ($end-$start) . "\n"; } ?> and it results with # if($a != 'hello') Used time: 12.552895069122 Used time: 12.548940896988 Used time: 12.470285177231 # if(!$a == 'hello') Used time: 7.6532161235809 Used time: 7.6426539421082 Used time: 7.6452689170837

« previous php.notes (#217880) next »