note 123025 deleted from function.sizeof by cmb

From: Date: Thu, 08 Nov 2018 00:38:46 +0000
Subject: note 123025 deleted from function.sizeof by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209640@lists.php.net to get a copy of this message
Note Submitter: septerrianin at mail dot ru ---- It's so fun to read people who believe that sizeof() is alias count(). Like PixEye or umopdn. NOTE: Don't use sizeof()! It's not alias of count()! sizeof() is slower that count()! Check it: <?php //Creating array with 1 000 000 elements $a = array(); for ($i = 0; $i < 1000000; ++$i) { $a[] = 100; } //Measure $time = time(); for ($i = 0; $i < 1000000000; ++$i) { $b = count($a); } print("1 000 000 000 iteration of count() taked ".(time()-$time)." sec\n"); $time = time(); for ($i = 0; $i < 1000000000; ++$i) { $b = sizeof($a); } print("1 000 000 000 iteration of sizeof() taked ".(time()-$time)." sec\n"); ?> Shown: 1 000 000 000 iteration of count() taked 20 sec 1 000 000 000 iteration of sizeof() taked 31 sec Any questions?

« previous php.notes (#209640) next »