{ $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"); print_r($un); echo "u=" . $u['u'] . "\n";
$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"); } } } catch (TokyoTyrantException $e) { if ($e->getCode() === TokyoTyrant::TTE_KEEP) { echo "Existing record! Not modified\n";