Re: SQL Functions

From: Date: Tue, 10 Aug 2004 16:13:21 +0000
Subject: Re: SQL Functions
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-193302@lists.php.net to get a copy of this message
Robby Russell wrote:
Run some tests and let us know. ;-) I'd be interested in knowing as well.
Not really worth worrying about according to this... array_push() averaged 0.20226655006409 seconds when running the test 10 times array[] averaged 0.20317406654358 seconds when running the test 10 times test script : <?php $push = array(); $brackets = array(); function getmicrotime() { list( $usec, $sec ) = explode( " ", microtime() ); return ( ( float ) $usec + ( float ) $sec ); } function testArrayStuff() { global $push, $brackets; $start = getmicrotime(); $array = array(); for ( $i = 0; $i < 100000; $i++ ) { array_push ( $array, $i ); } $stop = getmicrotime(); $duration = $stop - $start; array_push ( $push, $duration ); $start = getmicrotime(); $array = array(); for ( $i = 0; $i < 100000; $i++ ) { $array[] = $i; } $stop = getmicrotime(); $duration = $stop - $start; array_push ( $brackets, $duration ); } for ( $i = 0; $i < 10; $i++ ) { testArrayStuff(); } $push_size = sizeof ( $push ); $push_total = 0; for ( $i = 0; $i < $push_size; $i++ ) { $push_total += $push[$i]; } $bracket_size = sizeof ( $brackets ); $bracket_total = 0; for ( $i = 0; $i < $bracket_size; $i++ ) { $bracket_total += $brackets[$i]; } $push_average = $push_total / $push_size; $bracket_average = $bracket_total / $bracket_size; echo ( "array_push() averaged " . $push_average . " seconds when running the test " . $push_size . " times<br>\n" ); echo ( "array[] averaged " . $bracket_average . " seconds when running the test " . $bracket_size . " times<br>\n" ); ?> -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#193302) next »