predis的set速度测试

WBOY
Libérer: 2016-07-29 09:15:11
original
1250 Les gens l'ont consulté

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

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

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

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

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

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

测试代码:

<code><span><span><?php </span><span><strong>require</strong></span><span>'/home/xubo/cloud/redis/clients/predis/autoload.php'</span>;

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



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



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

   <span>echo</span><span>"$fn:$totaltime"</span>;


<span>?></span></span></code>
Copier après la connexion

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

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

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal