note 39035 deleted from function.array-push by irchtml

From: Date: Tue, 24 Feb 2004 08:57:54 +0000
Subject: note 39035 deleted from function.array-push by irchtml
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-65632@lists.php.net to get a copy of this message
Note Submitter: corrupted_wise@yahoo.com ---- Adding to confirm the post below(daijoubuNOSP at Mvideotron dot ca) I first tested this by looping through 50,000 times using only the [] method, then 50,000 using the array_push method. Both times started on empty arrays, since it was for loops, it only appended integers, nothing big. function FullMicroTime() { $mictime = explode(" ", microtime()); return Do8Digit((intval($mictime[1]) + floatval($mictime[0]))); } function Do8Digit($string) { return sprintf("%.8f", $string); } $test = $test2 = array(); $f_test_begin = FullMicroTime(); for($i = 0; $i <= 50000; $i++) { $test[] = $i; } $f_test_end = FullMicroTime(); $s_test_begin = FullMicroTime(); for($i = 0; $i <= 50000; $i++) { array_push($test2, $i); } $s_test_end = FullMicroTime(); $first_time = Do8Digit(($f_test_end - $f_test_begin)); $second_time = Do8Digit(($s_test_end - $s_test_begin)); print '[] method: ' . $first_time . "\n"; print 'push method: ' . $second_time . "\n"; print 'difference: ' . Do8Digit(($second_time - $first_time)) . "\n"; My results were: [] method: 0.37957907 push method: 0.46931005 difference: 0.08973098 It's not much, and i'm sure no one will loop 50,000 times, but it's proof.

« previous php.notes (#65632) next »