当前位置:Gxlcms > PHP教程 > predis的set速度测试

predis的set速度测试

时间:2021-07-01 10:21:17 帮助过:47人阅读

predis的set速度测试
redis、php、set:

set/get100000:
start:1442496208.9368
xubo0:0--time:0.00039482116699219s
xubo10000:10000--time:0.49174094200134s
xubo20000:20000--time:0.89022397994995s
xubo30000:30000--time:1.2952389717102s
xubo40000:40000--time:1.6944959163666s
xubo50000:50000--time:2.0859758853912s
xubo60000:60000--time:2.4891138076782s
xubo70000:70000--time:2.8911108970642s
xubo80000:80000--time:3.2922348976135s
xubo90000:90000--time:3.6980829238892s
end:1442496213.0497
s100000:4.1128277778625set/get100000:
start:1442496231.5078
xubo0:0--time:0.00056314468383789s
xubo10000:10000--time:0.39918899536133s
xubo20000:20000--time:0.80352401733398s
xubo30000:30000--time:1.2234301567078s
xubo40000:40000--time:1.6409831047058s
xubo50000:50000--time:2.057382106781s
xubo60000:60000--time:2.4619610309601s
xubo70000:70000--time:2.9444301128387s
xubo80000:80000--time:3.3929440975189s
xubo90000:90000--time:3.8406541347504s
end:1442496235.7982
s100000:4.2903289794922set/get100000:
start:1442496276.5454
xubo0:0--time:0.00068187713623047s
xubo10000:10000--time:0.47572684288025s
xubo20000:20000--time:0.94239592552185s
xubo30000:30000--time:1.4021549224854s
xubo40000:40000--time:1.8193259239197s
xubo50000:50000--time:2.2206959724426s
xubo60000:60000--time:2.6312279701233s
xubo70000:70000--time:3.0266840457916s
xubo80000:80000--time:3.4182560443878s
xubo90000:90000--time:3.8248949050903s
end:1442496280.7723
s100000:4.226863861084set/get100000:
start:1442496289.7032
xubo0:0--time:0.00063514709472656s
xubo10000:10000--time:0.39353799819946s
xubo20000:20000--time:0.79392194747925s
xubo30000:30000--time:1.1953980922699s
xubo40000:40000--time:1.6089961528778s
xubo50000:50000--time:2.0243270397186s
xubo60000:60000--time:2.4311549663544s
xubo70000:70000--time:2.8455491065979s
xubo80000:80000--time:3.2610011100769s
xubo90000:90000--time:3.6794910430908s
end:1442496293.7885
s100000:4.0852270126343

经过四次测试,predis的set指令100000次时间大概为4.15s

set/get1000000:
start:1442496958.0541
xubo0:0--time:0.00064611434936523s
xubo100000:100000--time:4.5391991138458s
xubo200000:200000--time:9.1131091117859s
xubo300000:300000--time:15.13695192337s
xubo400000:400000--time:21.497059106827s
xubo500000:500000--time:27.332253932953s
xubo600000:600000--time:32.020254135132s
xubo700000:700000--time:36.608731985092s
xubo800000:800000--time:41.137508153915s
xubo900000:900000--time:45.799643039703s
end:1442497008.3659
s1000000:50.311782121658set/get1000000:
start:1442497141.8665
xubo0:0--time:0.00071597099304199s
xubo100000:100000--time:5.2379097938538s
xubo200000:200000--time:10.768998861313s
xubo300000:300000--time:16.702248811722s
xubo400000:400000--time:21.393670797348s
xubo500000:500000--time:26.071841955185s
xubo600000:600000--time:30.615657806396s
xubo700000:700000--time:35.180080890656s
xubo800000:800000--time:39.755750894547s
xubo900000:900000--time:44.237802028656s
end:1442497190.5661
s1000000:48.699581861496set/get1000000:
start:1442497396.3979
xubo0:0--time:0.00040006637573242s
xubo100000:100000--time:4.4978289604187s
xubo200000:200000--time:9.2330050468445s
xubo300000:300000--time:14.044721841812s
xubo400000:400000--time:18.668016910553s
xubo500000:500000--time:23.322139024734s
xubo600000:600000--time:28.039067029953s
xubo700000:700000--time:32.682448863983s
xubo800000:800000--time:37.302042007446s
xubo900000:900000--time:42.112798929214s
end:1442497444.1373
s1000000:47.739441871643

经过三次测试,predis的set指令1000000次时间大概为48s

10000000次set的用php不好测,我用的是浏览器访问,时间长了返回不了结果,也没找到解决办法,如果有谁解决了求教!

测试代码:

require'/home/xubo/cloud/redis/clients/predis/autoload.php';

$redis = new Predis\Client([
      'scheme'=>'tcp',
      'host' => '127.0.0.1',
      'port' => 6379,
      'password' =>'foobared',
]);



//$client = new Predis\Client();$client = new Predis\Client([
      'scheme'=>'tcp',
      'host' => '127.0.0.1',
      'port' => 6379,
      'password' =>'foobared',
]);
$fn=100000;



//$client = new Predis\Client();$client = new Predis\Client([
      'scheme'=>'tcp',
      'host' => '127.0.0.1',
      'port' => 6379,
      'password' =>'foobared',
]);
$fn=100000;
      'port' => 6379,
      'password' =>'foobared',
]);
$fn=100000;
echo"
set/get $fn:
"
; $starttime=microtime(true); echo"start:$starttime
"
; for ($i=0;$i<$fn;$i++){ //$client = new Predis\Client();$client -> set("php$i",$i); if($i % ($fn/10)==0){ echo"xubo$i:"; echo$client->get("php$i"); $ntime=microtime(true); echo"--time:"; echo$ntime-$starttime; echo"s"; echo'
'
; } } $endtime=microtime(true); $totaltime=$endtime-$starttime; echo"end:$endtime
"
; echo"s"; echo"$fn:$totaltime"; ?>

版权声明:本文为博主原创文章,欢迎转载和交流!

以上就介绍了predis的set速度测试,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

人气教程排行