Пример #1
0
function record_time(&$start, $usage = "")
{
    $end = microtime(true);
    $cost = $end - $start;
    $cost = ceil(1000000 * $cost);
    if ($usage) {
        echo "{$usage} use time {$cost} us\n";
    }
    $start = $end;
}
echo "<pre>\n";
record_time($st);
try {
    /* Connect to a table database */
    $tt = new TokyoTyrantTable("localhost", 10000);
    record_time($st, "connect");
    echo "num of records:" . $tt->num() . "\n";
    record_time($st, "record");
    $q = $tt->getQuery();
    record_time($st, "getQuery");
    $id = rand() % 1000000 + 10;
    echo "id={$id}\n";
    $u = $tt->get($id);
    record_time($st, "get");
    $data[uniqid()] = 'new col';
    $data[uniqid()] = 'new col2';
    $uid = $tt->putCat($id, $data);
    record_time($st, "put");
    $un = $tt->get($id);
    record_time($st, "get");
Пример #2
0
 /**
  * 按id获取
  * @param $id
  * @return unknown_type
  */
 public function get($id)
 {
     $r = parent::get($id);
     $this->after_get($r);
     return $r;
 }
Пример #3
0
function record_time(&$start, $usage = "")
{
    $end = microtime(true);
    $cost = $end - $start;
    $cost = ceil(1000000 * $cost);
    if ($usage) {
        echo "{$usage} use time {$cost} us\n";
    }
    $start = $end;
}
echo "<pre>\n";
record_time($st);
try {
    /* Connect to a table database */
    $tt = new TokyoTyrantTable("localhost", 10000);
    record_time($st, "connect");
    for ($j = 0; $j < 30; $j++) {
        $data['field' . $j] = uniqid();
    }
    $start = floor($tt->num() / 100);
    echo "start={$start} \n";
    for ($i = 1; $i < 100000; $i++) {
        $cur = $i + $start;
        $data['u'] = $cur;
        for ($j = 0; $j < 100; $j++) {
            $data['v'] = $cur . ':' . rand() % 10;
            $tt->put(null, $data);
        }
        if ($cur % 100 == 0) {
            record_time($st, "insert {$cur}*100");