RE: [patch #6572] A test on using PDO in db-class

Sigurd Nes <[email protected]> Fri, 18 Jul 2008 13:50:10 +0200 (MEST)
Newsgroups gmane.comp.web.phpgroupware.devel
Message-ID <[email protected]>
> From: Dave Hall [[email protected]]
> Sent: 2008-07-18 11:23:24 CEST
> To: [email protected]
> Subject: Re: [phpGroupWare-developers] [patch #6572] A test on using PDO in	db-class
> 
> On Thu, 2008-07-17 at 23:50 +0200, Sigurd Nes wrote:
> > Hi all,
> > 
> > I did a test on using PDO for db-connection.
> > The code is based on the current db-class from trunk and the tutorial found at:
> > http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html
> > 
> > Seems like it is about 5 % faster on reading and 20 % faster on writing compared
> > to adodb with eaccelerator (had hoped for more).
> > 
> > The class is not 100% complete - but most of it works.
> > 
> > http://savannah.gnu.org/patch/download.php?file_id=16131
> > 
> > What do you think ?
> 
> Please post the test cases used to generate these stats so they can be
> verified.
> 

Yep - it is faster:

100.000 inserts and selects levels out on 14 sec and 3,5 sec for PDO and 21 sec and 6 sec for ADOdb.

That is 33% faster on insert and 42 % faster on select

See attachment to try it your self

Regards

Sigurd

_______________________________________________
phpGroupWare-developers mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/phpgroupware-developers
test_pdo.php (application/octet-stream, 2.5 KB)
<?php
	/**
	* phpGroupWare - property: a Facilities Management System.
	*
	* @author Sigurd Nes <[email protected]>
	* @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc. http://www.fsf.org/
	* This file is part of phpGroupWare.
	*
	* phpGroupWare is free software; you can redistribute it and/or modify
	* it under the terms of the GNU General Public License as published by
	* the Free Software Foundation; either version 2 of the License, or
	* (at your option) any later version.
	*
	* phpGroupWare is distributed in the hope that it will be useful,
	* but WITHOUT ANY WARRANTY; without even the implied warranty of
	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	* GNU General Public License for more details.
	*
	* You should have received a copy of the GNU General Public License
	* along with phpGroupWare; if not, write to the Free Software
	* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
	*
	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
	* @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
	* @package property
 	* @version $Id$
	*/

	/**
	 * Test script for PDO vs ADOdb
	 *
	 */

	$GLOBALS['phpgw_info']['flags'] = array
	(
		'currentapp'	=> 'property'
	);

	include_once('../header.inc.php');

	$type = 'ADOdb';
	$type = 'PDO';
	
	if($type == 'ADOdb')
	{
		$db = createObject('phpgwapi.db');
	}
	else
	{
		$db = createObject('property.db_pdo');
	}

	$db->transaction_begin();
	$sql = "CREATE TABLE pdo_test( id integer NOT NULL,  descr character varying(50), CONSTRAINT pdo_test_pkey PRIMARY KEY (id))";
	$db->query($sql,__LINE__,__FILE__,true);

	$j = 100000;

	$timer_start = perfgetmicrotime();
	
	for ($i=1; $i < $j+1; $i++)
	{
		$db->query('INSERT INTO pdo_test (id, descr)'
				. " VALUES ({$i}, 'Description for a tiny test at line {$i}')",__LINE__,__FILE__,true);
	}

	$timer_stop = perfgetmicrotime();
	echo "<p>Type: {$type}, INSERT count= {$j}, Time spent: " . ($timer_stop - $timer_start) . '<p></br>';

	$timer_start = perfgetmicrotime();

	$sql = "SELECT * FROM pdo_test ORDER BY id ASC";
	$db->query($sql,__LINE__,__FILE__);

	while($db->next_record())
	{
		$j = $db->f('id');
		$descr = $db->f('descr');
	}

	$timer_stop = perfgetmicrotime();
	echo "<p>Type: {$type}, SELECT count= {$j}, Time spent: " . ($timer_stop - $timer_start) . '<p></br>';

	$sql = "DROP TABLE pdo_test";
	$db->query($sql,__LINE__,__FILE__,true);
	$db->transaction_commit();

	exit;