pconnect.php3

text/plain

Filename: pconnect.php3
Type: text/plain
Part: 0
Message: Some performance issues (since everybody is testing ... :)
<html>
<head><title>Connect benchmark</title></head>
<body>

<?php
error_reporting(1);
$db = "ibase";

if(!IsSet($max)):
  $max  = 1000;
endif;

echo "<table border=1>";
echo "<tr><th colspan=2>Stressing postmaster with $max persistent connections</th></tr>";
echo "<tr><th align=left>Connection type</th><th align=right>Time (seconds)</th></tr>";
 
/*
 *	tcpip persistent connections
 */
$host = "localhost";
$port = "5432";

$tt = time();
for($i=0; $i<$max; $i++) {
  $conn = pg_pConnect($host, $port, "", "", $db);
  pg_Close($conn);
 }
$tt = time() - $tt;
echo "<tr><td>tcpip local</td><td align=right>$tt</td></tr>";

/*
 *	tcpip persistent connections with selects
 */
$host = "localhost";
$port = "5432";

$tt = time();
for($i=0; $i<$max; $i++) {
  $conn = pg_pConnect($host, $port, "", "", $db);
  $res  = pg_Exec($conn, "select 17");
  pg_Close($conn);
 }
$tt = time() - $tt;
echo "<tr><td>tcpip local with select</td><td align=right>$tt</td></tr>";

/*
 *	unix persistent sockets connections
 */
$host = "";
$port = "";

$tt = time();
for($i=0; $i<$max; $i++) {
  $conn = pg_pConnect($host, $port, "", "", $db);
  pg_Close($conn);
 }
$tt = time() - $tt;
echo "<tr><td>unix sockets</td><td align=right>$tt</td></tr>";

/*
 *	unix sockets persistent connections with selects
 */
$host = "";
$port = "";

$tt = time();
for($i=0; $i<$max; $i++) {
  $conn = pg_pConnect($host, $port, "", "", $db);
  $res  = pg_Exec($conn, "select 17");
  pg_Close($conn);
 }
$tt = time() - $tt;
echo "<tr><td>unix sockets with select</td><td align=right>$tt</td></tr>";
echo "</table>";
?>
</body>
</html>