note 120065 added to function.is-array

From: Date: Thu, 20 Oct 2016 12:08:10 +0000
Subject: note 120065 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-206928@lists.php.net to get a copy of this message
hperrin at gmail dot com i tested modified version of your code: <?php $test = array_fill(0, $size, rand()); $test3 = (object) $test; ?> Results are quite different! PHP 5.5: is_array - execution time is constant over different $size cast, === - execution time is proportional with $size, for small arrays, it's faster than is_array, but for bigger arrays, it's way slower. Also, bigger memory allocation because casting actually allocates memory PHP 7.0: is_array and cast, === have constant execution time over different $size: is_array : 0.12564396858215 cast, === : 0.24629783630371 Looks like casting is optimised, but still slower. Bottom line is: optimisation is not done for special scenario, but for average use and scalability. Don't reinvent wheel. ---- Server IP: 72.52.91.14 Probable Submitter: 213.149.51.135 ---- Manual Page -- http://php.net/manual/en/function.is-array.php Edit -- https://master.php.net/note/edit/120065 Del: integrated -- https://master.php.net/note/delete/120065/integrated Del: useless -- https://master.php.net/note/delete/120065/useless Del: bad code -- https://master.php.net/note/delete/120065/bad+code Del: spam -- https://master.php.net/note/delete/120065/spam Del: non-english -- https://master.php.net/note/delete/120065/non-english Del: in docs -- https://master.php.net/note/delete/120065/in+docs Del: other reasons-- https://master.php.net/note/delete/120065 Reject -- https://master.php.net/note/reject/120065 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206928) next »