Exemple #1
0
 /**
  * Deletes a DBA database from the filesystem
  *
  * @static
  * @param   string $driver type of storage object to return
  * @return  object DBA storage object, returned by reference
  */
 function db_drop($name, $driver = 'file')
 {
     if (!function_exists('dba_open') || $driver == 'file') {
         require_once 'DBA/Driver/File.php';
         return DBA_Driver_File::db_drop($name);
     } elseif (in_array($driver, DBA::getDriverList())) {
         require_once 'DBA/Driver/Builtin.php';
         return DBA_Driver_Builtin::db_drop($name);
     } else {
         return DBA::raiseError(DBA_ERROR_UNSUP_DRIVER, NULL, NULL, 'driver: ' . $driver);
     }
 }
//
ini_set('include_path', ini_get('include_path') . ':../../');
require_once 'DBA.php';
require_once 'PEAR.php';
$testDataArray = array('11111111111111111111', '222222222222222222222222', '3333333333333333333333333333', '44444444444444444444444444444444', '555555555555555555555555555555555555', '6666666666666666666666666666666666666666', '77777777777777777777777777777777777777777777', '888888888888888888888888888888888888888888888888', '9999999999999999999999999999999999999999999999999999');
$maxDataIndex = sizeof($testDataArray) - 1;
$maxTestKeys = array(1600, 3200, 6400, 12800, 25600);
$transactionsInterval = 2000;
$maxTransactions = $transactionsInterval * 8;
$prefix = './';
function getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}
foreach (DBA::getDriverList() as $driver) {
    echo "Benchmarking driver: {$driver}\n";
    $testDB = DBA::create($driver);
    foreach ($maxTestKeys as $maxTestKey) {
        $dat_fp = fopen($prefix . "{$driver}_{$maxTestKey}.dat", 'w');
        for ($transactions = $transactionsInterval; $transactions <= $maxTransactions; $transactions += $transactionsInterval) {
            $result = $testDB->open($prefix . 'benchmark_db_' . $driver, 'n');
            if (PEAR::isError($result)) {
                echo $result->getMessage() . "\n";
            } else {
                // only measure successful transactions
                $actualTransactions = 0;
                // begin stopwatch
                $start = getmicrotime();
                for ($i = 0; $i < $transactions; ++$i) {
                    $testKey = rand(0, $maxTestKey);