note 10571 deleted from Persistent Database Connections by jimw

From: Date: Fri, 12 Jan 2001 19:48:15 +0000
Subject: note 10571 deleted from Persistent Database Connections by jimw
Groups: php.notes 
Request: Send a blank email to php-notes+get-9723@lists.php.net to get a copy of this message
I liked the above script, so I thought I add to it by making a little loop so you can let it repeat itself. I'm not totally sure if my method is a theoretically sound of testing the speed differance, because I'm not completely sure how the location header influences the connecting, but for what it's worth: <? function microint() { $tmp = microtime(); $parts = explode(" ",$tmp); $floattime = (float)$parts[0] + (float)$parts[1]; return $floattime; } $starttime = microint(); $connect = mysql_pconnect("unixsql2.interland.net", "iponline", "64ip213"); $endtime = microint(); $persistent = $persistent + ($endtime - $starttime); $starttime = microint(); $connect = mysql_connect("xy.example.net", "luser", "secret"); $endtime = microint(); $no_persistent = $no_persistent + ($endtime - $starttime); $repeat++; if ($repeat != $Maxrepeat) { header("Location: $PHP_SELF?persistent=$persistent&no_persistent=$no_persistent&repeat=$repeat&Maxrepeat=$Maxrepeat "); } $avg_no_persistent = $no_persistent / $Maxrepeat; $avg_persistent = $persistent / $Maxrepeat; echo "Without persistent connection, average reconnection time was <b>$avg_no_persistent</b><BR>"; echo "With persistent, average reconnection time was <b>$avg_persistent</b><br>"; $percentage = $avg_no_persistent / $avg_persistent; echo "This is $percentage times faster.<br>"; echo "(Connection was reset <b>$Maxrepeat</b> times)"; ?>

« previous php.notes (#9723) next »