Ejemplo n.º 1
0
	$end = microtime(true);
	printf("    %f\n", $end - $start);
}

exit;
*/
for ($m = 0; $m < $NumberOfIndexes; $m++) {
    $Index = $SmrClient->getRankingIdByName('-Index@' . $m . ':' . $NumberOfEntriesPerIndexCapped);
    printf("Index: %d\n", $Index);
    //var_dump($SmrClient->setRanking(0, SmrClientDirection::Ascending, 10000000));
    $start = microtime(true);
    for ($n = 0; $n < $NumberOfEntriesToAddPerIndex; $n++) {
        //for ($n = 0; $n < 1000; $n++) {
        //for ($n = 0; $n < 100; $n++) {
        //for ($n = 0; $n < 20; $n++) {
        $SmrClient->setElementBuffer($Index, $n, mt_rand(0, 500), $time + mt_rand(-50, 4));
    }
    $SmrClient->setElementBuffer($Index, 1000, 200, $time);
    $SmrClient->setElementBuffer($Index, 1001, 300, $time);
    $SmrClient->setElementBuffer($Index, 1000, 300, $time + 1);
    $SmrClient->setElementBufferFlush($Index);
    $end = microtime(true);
    printf("    %f\n", $end - $start);
    //$SmrClient->setElementBufferFlush();
    /*
    printf("Position(1000):%d\n", $pos_1000 = $SmrClient->getElementOffset($Index, 1000));
    print_r($SmrClient->listElements($Index, $pos_1000, 3));
    
    printf("Position(1001):%d\n", $pos_1001 = $SmrClient->getElementOffset($Index, 1001));
    print_r($SmrClient->listElements($Index, $pos_1001, 3));
    
Ejemplo n.º 2
0
        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);
assertAreEqual(array('id' => 0, 'treeHeight' => -1, 'maxElements' => -1, 'bottomScore' => 100, 'topScore' => 400, 'direction' => -1, 'length' => 4, 'result' => 0), $client->getRankingInfo($index));
assertAreEqual(array(array('position' => 0, 'elementId' => 1001, 'score' => 400, 'timestamp' => 1322747689), array('position' => 1, 'elementId' => 1000, 'score' => 320, 'timestamp' => 1322747690), array('position' => 2, 'elementId' => 1002, 'score' => 200, 'timestamp' => 1322747690), array('position' => 3, 'elementId' => 1003, 'score' => 100, 'timestamp' => 1322747690)), $client->listElements($index, $offset = 0, $count = 10));
assertAreEqual(array(array('position' => 1, 'elementId' => 1000, 'score' => 320, 'timestamp' => 1322747690), array('position' => 2, 'elementId' => 1002, 'score' => 200, 'timestamp' => 1322747690)), $client->listElements($index, $offset = 1, $count = 2));
assertAreEqual(array(), $client->listElements($index, $offset = -1, $count = 10));
assertAreEqual(2, $client->getElementOffset($index, 1002));