PHP Classes

File: myXTree/speed_test.php

Recommend this page to a friend!
  Classes of Tereshchenko Andrey   myXTree   myXTree/speed_test.php   Download  
File: myXTree/speed_test.php
Role: Application script
Content type: text/plain
Description: Speed test script
Class: myXTree
myXTree is an interface to a SQL-tree.
Author: By
Last change:
Date: 19 years ago
Size: 1,898 bytes
 

Contents

Class file image Download
<?php
/**
* In front of use of this test necessary to create a database in mySQL.
* SQL queries for creation of tables can be taken from file base.sql in root
* directory. After it need specified the linking up parameters to database
* beneath in this test or in file config.ini.
*
* NOTE: For correct job of tests the database should be empty. Use SQL-queries
* only from a file base.sql and do not fill in base the data from a file
* tree.sql.
*/

$user = 'root';
$pass = '';
$host = 'localhost';
$name = 'myXTree';
$prefix = 'xt_';

$root = $_SERVER['DOCUMENT_ROOT'];
$config['PATH']['pear'] = $root.'/PEAR';
$config['PATH']['myxml'] = $root.'/myXML';
$config['PATH']['myxtree'] = $root.'/myXTree';

function
getmicrotime() {
   list(
$usec, $sec) = explode(" ", microtime());
   return ((float)
$usec + (float)$sec);
}
$time_start = getmicrotime();

if (
file_exists('config.ini')) {
   
$config = parse_ini_file('config.ini', true);
   
extract($config['DB'], EXTR_OVERWRITE);
}

$dsn = "mysql://$user:$pass@$host/$name";

if (
substr(PHP_OS, 0, 3) == 'WIN') {
   
$searchPath = implode(';', $config['PATH']).';';
} else {
   
$searchPath = implode(':', $config['PATH']).':';
}
// Set the search path.
ini_set('include_path', $searchPath);

require_once(
'PHPUnit.php');
require_once(
'tests/speed.php');
require_once(
'myDOM/myDOM.php');
require_once(
'DB.php');

$db = DB::connect($dsn);
PEAR::isError($db) and
   
raiseError($db->getMessage());
   
$xtree =& myXTree::create($db, $prefix);
print
str_repeat(' ', 256);flush();
print(
'<br><br>Start speed test with distribution of nodes #1');flush();
$speed = new SpeedTest(&$xtree);
$speed->start();

print(
'<br><br>Start speed test with distribution of nodes #2');flush();
$speed->childs = 5;
$speed->start();

$GLOBALS['_PEAR_destructor_object_list'] = array();

?>