redis的pipeline測試分析

先上程序:

<?php
$redis = new Redis();   
$redis->connect('127.0.0.1', 6379);
$starttime = explode(" ",microtime());
$pipe = $redis->multi(Redis::PIPELINE);   
for ($i = 0; $i <  10000; $i++) {   
    $pipe->set("key::$i", str_pad($i, 4, '0', 0));   
    $pipe->get("key::$i");   
}   
      
$replies = $pipe->exec(); 
//echo " "; print_r($replies);

$endtime = explode(" ",microtime());

$thistime = $endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]);
$thistime = round($thistime,3);
echo $thistime;
echo "\r\n";

$a = array();
$starttime1 = explode(" ",microtime());
for($i= 0;$i<10000;$i++){
	$redis->set("key::$i", str_pad($i, 4, '0', 0));
}
for($i=0;$i<10000;$i++){
	array_push($a, $redis->get("key::$i"));
}

//print_r($a);
$endtime1 = explode(" ",microtime());
$thistime = $endtime1[0]+$endtime1[1]-($starttime1[0]+$starttime1[1]);
$thistime = round($thistime,3);
echo $thistime;
echo "\r\n";


執行時間統計:


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章