<?php
/**
* Example of using CBenchmark class to benchmark code coverage
* and functions
*
*/
require_once('clsBenchMark.php');
require_once('example.classes.php');
$bench=new CBenchmark();
/**
* Benchmark Sqlite initialization
*/
$bench->Start('Init Sqlite');
$sqlite=new SQLite();
$sqlite->Open('c:\\myfile.db');
$bench->End('Init Sqlite');
/**
* Benchmark MySQL initialization
*/
$bench->Start('Init MySQL');
$mysql=new MySQL();
$mysql->Open('localhost','root','','mytest');
$bench->End();
$bench->do_benchmark('SQLite Insert','test_db_insert',array(TIMES,&$sqlite));
$bench->do_benchmark('SQLite Select','test_db_select',array(TIMES,&$sqlite));
$bench->do_benchmark('MySQL Insert','test_db_insert',array(TIMES,&$mysql));
$bench->do_benchmark('MySQL Select','test_db_select',array(TIMES,&$mysql));
$bench->ShowResults();
function test_db_insert($times,&$obj){
$obj->Query('delete from test');
for ($i=0;$i<$times;$i++){
$obj->Query('INSERT INTO test (a) VALUES ('.$i.')');
}
}
function test_db_select($times,&$obj){
for($i=0;$i<$times;$i++)
$obj->Query('SELECT * FROM test');
}
?>