Skip to content
This repository
tree: 5cd91f87df
Fetching contributors…

Cannot retrieve contributors at this time

file 52 lines (33 sloc) 0.989 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<?php

set_include_path(implode(PATH_SEPARATOR, array(
    realpath('../library'),
    get_include_path(),
)));


// STREAM

print 'Benchmark stream: ';

require_once 'Rediska.php';

$startTime = microtime(true);

$rediska = new Rediska(array(
    'servers' => array(array('host' => '127.0.0.1', 'port' => 6379))
));

$value = str_repeat('a', 1000000);

for ($i = 0; $i <= 1000; $i++) {
    $rediska->set('test', $value);
    $rediska->get('test');
    $rediska->delete('test');
}

$elapsedTime = microtime(true) - $startTime;

print sprintf('%.4f', $elapsedTime) . "\n";


// SOCKET

print 'Benchmark socket: ';

$startTime = microtime(true);

$rediska = new Rediska(array(
    'servers' => array(array('host' => '127.0.0.1', 'port' => 6379, 'useSocket' => true))
));

for ($i = 0; $i <= 1000; $i++) {
    $rediska->set('test', $value);
    $rediska->get('test');
    $rediska->delete('test');
}

$elapsedTime = microtime(true) - $startTime;

print sprintf('%.4f', $elapsedTime) . "\n";
Something went wrong with that request. Please try again.