<?php require_once __DIR__ . '/smr-client.php'; $SmrClient = new SmrClient(); $SmrClient->connect('127.0.0.1', 9777); /* exit; $start = microtime(true); for ($n = 0; $n < 1000; $n++) { $SmrClient = new SmrClient(); $SmrClient->connect('127.0.0.1', 9777); } $end = microtime(true); printf("%.6f\n", $end - $start); exit; */ $time = time(); //$SmrClient->removeAllElements(0); /* $start = microtime(true); //for ($n = 0; $n < 30000; $n++) { //for ($n = 0; $n < 10000; $n++) { for ($n = 0; $n < 1000; $n++) { //for ($n = 0; $n < 1; $n++) { $SmrClient->getVersion(); } $end = microtime(true); printf("Time: %.4f\n", $end - $start); exit; */
$backtrace = debug_backtrace(); $backrow = $backtrace[0]; list($file, $line) = array($backrow['file'], $backrow['line']); if ($expected != $actual) { $lines = file($file); print_r($expected); echo " != \n"; print_r($actual); throw new Exception("Assert failed on '{$file}:{$line}' :: " . trim($lines[$line - 1])); } } //$port = 9999; $port = 11111; $server = new SimpleMassiveServer($port); $server->start(); $client = new SmrClient(); $client->connect('127.0.0.1', $port); $index = $client->getRankingIdByName('-testIndex:99'); assertAreEqual(array('id' => 0, 'treeHeight' => -1, 'maxElements' => -1, 'bottomScore' => 0, 'topScore' => 0, 'direction' => -1, 'length' => 0, 'result' => 0, 'name' => '-testIndex:99'), $client->getRankingInfoAndName($index)); $time = 1322747689; $client->setElementBuffer($index, $elementId = 1000, $score = 300, $timestamp = $time); $client->setElementBuffer($index, $elementId = 1001, $score = 400, $timestamp = $time); $client->setElementBuffer($index, $elementId = 1001, $score = 350, $timestamp = $time + 1); $client->setElementBuffer($index, $elementId = 1000, $score = 320, $timestamp = $time + 1); $client->setElementBuffer($index, $elementId = 1000, $score = 300, $timestamp = $time + 2); $client->setElementBuffer($index, $elementId = 1002, $score = 200, $timestamp = $time + 1); $client->setElementBuffer($index, $elementId = 1003, $score = 100, $timestamp = $time + 1); $client->setElementBuffer($index, $elementId = 1000, $score = 300, $timestamp = $time + 2); //$client->setElementBuffer($index, $elementId = 1000, $score = 10000, $timestamp = $time + 100); //print_r($client->listElements($index, $offset = 0, $count = 10)); exit; $client->setElementBufferFlush($index);