Hi!
I tried both of this libraries for use with DB. And i have some interesting result about the speed.
I noticed that PEAR is much much slower than PHPlib.
here is the results and the both codes.
PHPLib result
[total] => 0.046570
PEAR result
[total] => 2.187951
I execute the code below. The only diference is what class i used. I also use benchmark and put some markers to se how long does it takes 1000 connections to mysql server.
I tried this on the same machine and same software (PHP 4.0.5, Apache 1.3.20, win2000)
PHPlib 7.2c and pear wich comes with php.
If i vs. this, the PEAR is 47 times slower than PHP lib. I want to know why and if i'm doing something wrong. If this times is OK, than i this that DB PEAR is a crap.
PHPLIB
include("benchmark/timer.php");
$timer = new Benchmark_Timer;
$timer->start();
require_once 'db_mysql.inc';
$timer->setMarker('Marker 1');
$user = 'root';
$pass = '';
$host = 'localhost';
$db_name = 'test';
$db = new DB_Sql;
for ($n;$n<1000;$n++) {
$db -> connect($db_name,$host, $user, $pass);
}
$timer->setMarker('Marker 2');
$timer->stop();
$profiling = $timer->getProfiling();
echo "<pre>";
print_r($profiling);
PEAR
include("benchmark/timer.php");
$timer = new Benchmark_Timer;
$timer->start();
require_once 'DB.php';
$timer->setMarker('Marker 1');
$user = 'root';
$pass = '';
$host = 'localhost';
$db_name = 'test';
for ($n;$n<1000;$n++) {
$db = DB::connect("mysql://$user:$pass@$host/$db_name",true);
}
$timer->setMarker('Marker 2');
$timer->stop();
$profiling = $timer->getProfiling();
echo "<pre>";
print_r($profiling);