Home > Backend Development > PHP Tutorial > Predis set speed test

Predis set speed test

WBOY
Release: 2016-07-29 09:15:11
Original
1262 people have browsed it

predis set speed test
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>
Copy after login

After four tests, the time for predis's set command to be used 100,000 times is about 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>
Copy after login

After three tests, the time for predis's set command to be used 1,000,000 times is about 48s

10,000,000 times for set using php It’s not easy to test. I use a browser to access it. After a long time, the results cannot be returned and I haven’t found a solution. If anyone has solved it, please give me some advice!

Test code:

<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>
Copy after login

Copyright statement: This article is an original article by the blogger. Reprinting and communication are welcome!

The above introduces the set speed test of predis, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template