예제 #1
0
<?php

include 'parallel-const.php';
// 2^2 = 4 processes
if (pcntl_fork()) {
    usleep(mt_rand(0, 10000000));
}
// sleep for some interval...
if (pcntl_fork()) {
    usleep(mt_rand(0, 10000000));
}
// sleep for some interval...
//if(pcntl_fork()) usleep(mt_rand(0,10000000)); // sleep for some interval...
//if(pcntl_fork()) usleep(mt_rand(0,10000000)); // sleep for some interval...
//if(pcntl_fork()) usleep(mt_rand(0,10000000)); // sleep for some interval...
//if(pcntl_fork()) usleep(mt_rand(0,10000000)); // sleep for some interval...
$pid = posix_getpid();
// it is essential to initialize YNDb AFTER fork()
$MOO = new YNDb('./data');
for ($i = 0; $i < NUM_SELECTS; $i++) {
    $br = mt_rand(0, INSERT_VALUES / AVG_BAD_RAND);
    echo "{$pid} Begins select #{$i} with {$br}\n";
    $res = $MOO->select('test', array('cond' => array(array('bad_rand', '=', $br)), 'limit' => INSERT_VALUES));
    echo "{$pid} Selected " . sizeof($res) . " rows (excepted around " . AVG_BAD_RAND . " rows)\n";
    echo "{$pid} Begin results testing\n";
    foreach ($res as $k => $v) {
        if ($v['bad_rand'] != $br) {
            die('Invalid row #' . $k . ': ' . print_r($v, true));
        }
    }
}
예제 #2
0
파일: test.php 프로젝트: sibero/moosql
     		
     		$end = microtime(true);
     		
     		echo 'MySQL: '.floor($i / ($end-$start)).' ins/sec<br>';
     		flush();
     		//*/
     /*$start = microtime(true);
     		$sss = file_get_contents('../.data/test3.dat');
     		$end = microtime(true);
     		echo '<br>read the whole table: '.($end - $start).' sec<br>';
     		*/
     break;
 case 'select':
     echo '<h2>bad_rand = 8</h2>';
     $start = microtime(true);
     $res = $db->select(TABLE, array('col' => 'rand,id,bad_rand,data,another_rand,another_bad_rand', 'order' => 'id', 'limit' => '1000', 'cond' => 'bad_rand = 8'));
     $end = microtime(true);
     print_res($res);
     echo round($end - $start, 6) . ' sec / select (' . sizeof($res) . ' rows)<br>';
     echo '<h2>another_bad_rand = 25</h2>';
     $start = microtime(true);
     $res = $db->select(TABLE, array('col' => 'rand,id,bad_rand,data,another_rand,another_bad_rand', 'order' => 'id', 'limit' => '1000', 'cond' => 'another_bad_rand = 25'));
     $end = microtime(true);
     print_res($res);
     echo round($end - $start, 6) . ' sec / select (' . sizeof($res) . ' rows)<br>';
     echo '<h2>bad_rand = 35</h2>';
     $start = microtime(true);
     $res = $db->select(TABLE, array('col' => 'rand,id,bad_rand,data', 'order' => 'id', 'limit' => '1000', 'cond' => 'bad_rand = 35'));
     $end = microtime(true);
     print_res($res);
     echo round($end - $start, 6) . ' sec / select (' . sizeof($res) . ' rows)<br>';