note 119760 deleted from function.extract by mazzanet

From: Date: Fri, 19 Aug 2016 12:51:26 +0000
Subject: note 119760 deleted from function.extract by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206322@lists.php.net to get a copy of this message
Note Submitter: carte-sd ---- This function is very slow : echo PHP_VERSION; // 7.0.8 $test_array = array('id' => 1, 'nom' => 'Onche'); $start = microtime(true); //for + extract() for ($i = 0; $i < 100000; $i++): extract($test_array, EXTR_OVERWRITE); endfor; $end = microtime(true); $time = $end - $start; var_dump($time); // 0.14039993286133 // for $start = microtime(true); for ($i = 0; $i < 100000; $i++): $id = $test_array['id']; $nom = $test_array['nom']; endfor; $end = microtime(true); $time = $end - $start; var_dump($time); // 0.031199932098389 //for + foreach $start = microtime(true); for ($i = 0; $i < 100000; $i++): foreach($test_array as $key => $value): ${$key} = $value; endforeach; endfor; $end = microtime(true); $time = $end - $start; var_dump($time); // 0.093600988388062

« previous php.notes (#206322) next »