predis的set速度測試

來源:互聯網
上載者:User
predis的set速度測試
redis、php、set:

set/get100000:start:1442496208.9368xubo0:0--time:0.00039482116699219sxubo10000:10000--time:0.49174094200134sxubo20000:20000--time:0.89022397994995sxubo30000:30000--time:1.2952389717102sxubo40000:40000--time:1.6944959163666sxubo50000:50000--time:2.0859758853912sxubo60000:60000--time:2.4891138076782sxubo70000:70000--time:2.8911108970642sxubo80000:80000--time:3.2922348976135sxubo90000:90000--time:3.6980829238892send:1442496213.0497s100000:4.1128277778625set/get100000:start:1442496231.5078xubo0:0--time:0.00056314468383789sxubo10000:10000--time:0.39918899536133sxubo20000:20000--time:0.80352401733398sxubo30000:30000--time:1.2234301567078sxubo40000:40000--time:1.6409831047058sxubo50000:50000--time:2.057382106781sxubo60000:60000--time:2.4619610309601sxubo70000:70000--time:2.9444301128387sxubo80000:80000--time:3.3929440975189sxubo90000:90000--time:3.8406541347504send:1442496235.7982s100000:4.2903289794922set/get100000:start:1442496276.5454xubo0:0--time:0.00068187713623047sxubo10000:10000--time:0.47572684288025sxubo20000:20000--time:0.94239592552185sxubo30000:30000--time:1.4021549224854sxubo40000:40000--time:1.8193259239197sxubo50000:50000--time:2.2206959724426sxubo60000:60000--time:2.6312279701233sxubo70000:70000--time:3.0266840457916sxubo80000:80000--time:3.4182560443878sxubo90000:90000--time:3.8248949050903send:1442496280.7723s100000:4.226863861084set/get100000:start:1442496289.7032xubo0:0--time:0.00063514709472656sxubo10000:10000--time:0.39353799819946sxubo20000:20000--time:0.79392194747925sxubo30000:30000--time:1.1953980922699sxubo40000:40000--time:1.6089961528778sxubo50000:50000--time:2.0243270397186sxubo60000:60000--time:2.4311549663544sxubo70000:70000--time:2.8455491065979sxubo80000:80000--time:3.2610011100769sxubo90000:90000--time:3.6794910430908send:1442496293.7885s100000:4.0852270126343

經過四次測試,predis的set指令100000次時間大概為4.15s

set/get1000000:start:1442496958.0541xubo0:0--time:0.00064611434936523sxubo100000:100000--time:4.5391991138458sxubo200000:200000--time:9.1131091117859sxubo300000:300000--time:15.13695192337sxubo400000:400000--time:21.497059106827sxubo500000:500000--time:27.332253932953sxubo600000:600000--time:32.020254135132sxubo700000:700000--time:36.608731985092sxubo800000:800000--time:41.137508153915sxubo900000:900000--time:45.799643039703send:1442497008.3659s1000000:50.311782121658set/get1000000:start:1442497141.8665xubo0:0--time:0.00071597099304199sxubo100000:100000--time:5.2379097938538sxubo200000:200000--time:10.768998861313sxubo300000:300000--time:16.702248811722sxubo400000:400000--time:21.393670797348sxubo500000:500000--time:26.071841955185sxubo600000:600000--time:30.615657806396sxubo700000:700000--time:35.180080890656sxubo800000:800000--time:39.755750894547sxubo900000:900000--time:44.237802028656send:1442497190.5661s1000000:48.699581861496set/get1000000:start:1442497396.3979xubo0:0--time:0.00040006637573242sxubo100000:100000--time:4.4978289604187sxubo200000:200000--time:9.2330050468445sxubo300000:300000--time:14.044721841812sxubo400000:400000--time:18.668016910553sxubo500000:500000--time:23.322139024734sxubo600000:600000--time:28.039067029953sxubo700000:700000--time:32.682448863983sxubo800000:800000--time:37.302042007446sxubo900000:900000--time:42.112798929214send:1442497444.1373s1000000: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教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.