Ejemplo n.º 1
0
//pcntl_fork();
//$pid = 0;
echo "Initializing YNDb\n";
$MOO = new YNDb('data');
echo "Create table test\n";
try {
    $MOO->create('test', array('id' => 'INT', 'bad_rand' => 'INT', 'name' => 'TINYTEXT'), array('AUTO_INCREMENT' => 'id', 'INDEX' => array('bad_rand')));
} catch (Exception $e) {
    echo "Caught exception: " . $e->getMessage() . "\n";
}
usleep(1000);
// sleep just a moment to ensure that table is created
echo "Inserting " . INSERT_VALUES . " values\n";
for ($i = 0; $i < INSERT_VALUES; $i++) {
    if ($i % 50 == 0) {
        echo 'Inserted ' . $MOO->insert_id() . "\n";
    }
    $br = mt_rand(0, INSERT_VALUES / AVG_BAD_RAND);
    //echo 'inserting br = '.$br."\n";
    $MOO->insert('test', array('name' => 'entry #' . $i, 'bad_rand' => $br));
    //
}
echo "Last insert ID: " . $MOO->insert_id() . "\n";
/*if($pid == 0)
{
	return 0;
}else
{
	pcntl_waitpid($pid, $status);
	
	echo "Child status: $status\n";
Ejemplo n.º 2
0
                echo $i . ' ';
                flush();
            }
        }
        //$db->unlock_table(TABLE);
        $end = microtime(true);
        $tm = $end - $start;
        echo '<br>' . floor($i / $tm) . ' ins/sec (inserted eight ' . $i8 . ' times, inserted twenty five ' . $ia25 . ' times).<br>
Primary index took ' . round($primary_time / $tm * 100) . '%<br>
Lock table took ' . round($lock_time / $tm * 100) . '%<br>
Unique took ' . round($unique_time / $tm * 100) . '%<br>
Index took ' . round($index_time / $tm * 100) . '%<br>
<b>B-Tree:</b><br>
Read block took ' . round($read_block_time / $tm * 100) . '%<br>
Write block took ' . round($write_block_time / $tm * 100) . '%<br>
Last ins_id: ' . $db->insert_id() . '<br>
';
        flush();
        //*/
        /*
        		echo 'inserting to MySQL<br>';
        		
        		
        		mysql_connect('localhost', 'root', '');
        		mysql_select_db('guestbook_db');
        		
        		$start = microtime(true);
        		
        		
        		echo '<!-- '.str_repeat('-', 1024).' -->';