>  기사  >  백엔드 개발  >  Predis 설정 속도 테스트

Predis 설정 속도 테스트

WBOY
WBOY원래의
2016-07-29 09:15:111251검색

predis 설정 속도 테스트
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>

4번의 테스트 후 predis set 명령은 약 4.15초 안에 100,000번 걸립니다.

<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>

3번의 테스트 후 predis set 명령은 1,000,000번 걸립니다. 시간은 약 48초입니다

PHP를 사용하여 10000000번 설정하면 테스트하기가 어렵습니다. 오랜 시간이 지나도 결과가 반환되지 않으며 해결 방법을 찾지 못했습니다. 해결했습니다. 조언 좀 부탁드립니다!

테스트 코드:

<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>"</br>set/get $fn:</br>"</span>;
<span>$starttime</span>=microtime(<span>true</span>);
<span>echo</span><span>"start:$starttime</br>"</span>;
<span>for</span> (<span>$i</span>=<span>0</span>;<span>$i</span><<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>'</br>'</span>; 
   }
}
<span>$endtime</span>=microtime(<span>true</span>);
<span>$totaltime</span>=<span>$endtime</span>-<span>$starttime</span>;
<span>echo</span><span>"end:$endtime</br>"</span>;
   <span>echo</span><span>"s"</span>;

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


<span>?></span></span></span></code>

저작권: 이 글은 블로거의 원본 글이므로 재인쇄 및 교환을 환영합니다!

위의 내용을 포함하여 predis의 설정 속도 테스트를 소개합니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.