See, there's also a time needed for the server to read the included file -
an extra effort for your hard disk.
If you'd put everything in one file it would work for you faster, but, of
course, less portable. 

Though, I don't understand why are your performance measures THAT different.

Cheers,
Maxim Maletsky



-----Original Message-----
From: Artyom Plouzhnikoff [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 14, 2001 2:22 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Classes and performance bottlenecks


I have a strange problem with PHP 4.0.4pl1 and above. It looks like
including 
a file that contains classes can become a major performance bottleneck

My machine is an Intel Pentium ]I[ 667Mhz, 128Mb RAM running RedHat Linux 
7.1; I installed PHP as a DSO module. I used ab (Apache Benchmark) for 
benchmarking. The following application runs a very simple query and outputs

the result:

<?php
  $db = pg_pconnect("dbname=jokes user=foo password=xxxxxxxxx");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
  <title>test</title>
</head>
<body>
  <?php
    $res = pg_exec($db, "SELECT * FROM j_jokes ORDER BY posted DESC LIMIT 
10");
    echo "<table>";
    for ($i=0; $i<pg_numrows($res);$i++)
    {
      echo "<tr>";
      $row = pg_fetch_row($res, $i);
      for ($c=0;$c<count($row);$c++) echo "<td>$row[$c]</td>";
      echo "</tr>";
    }
    echo "</table>";
  ?>
</body>
</html>

It can process up to 200 requests per second depending on the size of the 
dataset. Sometimes it can do even more than that. I didn't optimize Apache 
and PostgreSQL for performance.

However, the following "application"
<?php 
  require_once("Smarty.class.php");
  require_once("DB.php");
?>

can process about 25 requests per second. 

  My applications use Smarty, Pear DB and my own classes from several
include 
files. Thus, they can hardly handle 10 requests per second. I tried to 
benchmark them in many different ways and I figured out that *including* a 
class takes a lot of time. Using those classes doesn't seem to change 
anything dramatically.
  Is it an inherent problem of using classes with PHP or is there something
I 
can do about it?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to