MDB structure question
| From: | Lukas Smith | Date: | Mon, 24 Jun 2002 11:32:36 +0000 |
| Subject: | MDB structure question | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-7322@lists.php.net to get a copy of this message | ||
|Hi,
a while back I introduced a structural change to MDB that I borrowed
from Manuels latest Metabase beta:
All the management related methods were moved to a separate class. If
the method is now called MDB checks if an instance of that class has
already been created and if not creates it and then the call is
"proxied" to the class.
So for the user nothing really changed.
The structure sort of looks like this now
MDB_common
|
|
|-(proxy)- MDB_manager_database_class
| |
| |
| ---- MDB_manager_mysql_class
|
--- MDB_mysql
So MDB_mysql extends MDB_common and MDB_manager_mysql_class extends
MDB_manager_database_class and MDB_common proxies calls to
MDB_manager_database_class
For example in MDB_common alter table now looks like:
function alterTable($name, &$changes, $check)
{
$result = $this->loadManager("Alter table");
if (MDB::isError($result)) {
return ($result);
}
return ($this->manager->alterTable($this, $name, $changes,
$check));
}
So the number of methods really stay the same.
The Mysql driver is smaller now though in terms of code (down from 80k
its now at 50k).
Obviously calling a management method now has a bit more overhead. The
management class however is only instantiated once. So after the first
call the overhead is much less for the next calls.
I did some benchmarks (using John Lims benchmark suite) with and without
this structure with the latest MDB version and the results are as
follows:
MDB with proxy: Queried 400 times in a couple runs evened out to about
9.83 seconds
MDB without proxy: Queried 400 times in a couple runs evened out to
about 9.88 seconds
The benchmark suite is not all that exact and I am not working my butt
of to ensure that it can produce totally accurate results (nor am I
experienced enough in running benchmarks to begin with). But it looks
like using the proxy (as it can be found in the current MDB release)
seems to give a very little performance boost if you dont use the
management methods. It does add a bit of structural complexity though.
So the question is:
Should I remove the proxy stuff or not?
As an aside:
Stripping down both the common.php and mysql.php to only the needed
methods (5k and 11k respectively) resulted in about 9.78 seconds.
All in all I expected a much greater influence from parsing and
compiling. With a script cacher this should be close to no difference?
Best regards,
Lukas Smith
smith@dybnet.de
_______________________________
DybNet Internet Solutions GbR
Reuchlinstr. 10-11
Gebäude 4 1.OG Raum 6 (4.1.6)
10553 Berlin
Germany
Tel. : +49 30 83 22 50 00
Fax : +49 30 83 22 50 07
www.dybnet.de info@dybnet.de