Rumah > php教程 > php手册 > java php 速度:实测java 与php运行速度比较

java php 速度:实测java 与php运行速度比较

WBOY
Lepaskan: 2016-06-21 08:50:10
asal
3002 orang telah melayarinya

java如下
 

<ol class="dp-j">
<li class="alt"><span><span class="keyword">public</span><span> </span><span class="keyword">class</span><span> aa{ </span></span></li>
<li><span><span class="keyword">public</span><span> </span><span class="keyword">static</span><span> </span><span class="keyword">void</span><span> main(String[] args){ </span></span></li>
<li class="alt"><span>System.out.println(System.currentTimeMillis()+<span class="string">"----"</span><span>); </span></span></li>
<li><span><span class="keyword">int</span><span> a=</span><span class="number">0</span><span>; </span></span></li>
<li class="alt"><span><span class="keyword">int</span><span> i; </span></span></li>
<li><span><span class="keyword">for</span><span>(i=</span><span class="number">0</span><span>;i<span class="number">10000000</span><span>;i++){ </span></span></span></li>
<li class="alt"><span>a++; </span></li>
<li><span>} </span></li>
<li class="alt"><span>System.out.println(System.currentTimeMillis()); </span></li>
<li><span>} </span></li>
<li class="alt"><span>} </span></li>
</ol>
Salin selepas log masuk


php如下
 

<ol class="dp-c">
<li class="alt"><span><span> </span></span></li>
<li><span><span class="func">echo</span><span> microtime(); </span></span></li>
<li class="alt"><span><span class="vars">$n</span><span>=0; </span></span></li>
<li><span><span class="keyword">for</span><span>(</span><span class="vars">$i</span><span>=0;</span><span class="vars">$i</span><span><span class="vars">$i</span><span>++){ </span></span></span></li>
<li class="alt"><span><span class="vars">$n</span><span>++; </span></span></li>
<li><span>} </span></li>
<li class="alt"><span><span class="func">echo</span><span> </span><span class="string">'----'</span><span>.microtime(); </span></span></li>
<li><span>?> </span></li>
</ol>
Salin selepas log masuk


同样都是循环一千万次
运行结果如下
java用时0.015秒
php用时0.726秒
java的速度是php的48倍,差别居然这么大!!

本文链接http://www.cxybl.com/html/wlbc/Php/20130316/37179.html



Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan