欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP中strtr與str_replace函數(shù)運(yùn)行性能簡(jiǎn)單測(cè)試示例

 更新時(shí)間:2019年06月22日 08:44:11   作者:小問(wèn)_  
這篇文章主要介紹了PHP中strtr與str_replace函數(shù)運(yùn)行性能簡(jiǎn)單測(cè)試,結(jié)合具體實(shí)例形式對(duì)比分析了PHP中strtr與str_replace函數(shù)的測(cè)試運(yùn)行效率,需要的朋友可以參考下

本文實(shí)例講述了PHP中strtr與str_replace函數(shù)運(yùn)行性能簡(jiǎn)單測(cè)試。分享給大家供大家參考,具體如下:

strtr與str_replace函數(shù)性能,很簡(jiǎn)單的一個(gè)測(cè)試,只是簡(jiǎn)單的測(cè)下,供參考,代碼如下:

<?php
require_once('Timer.php');
$target = 'qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./qwertyuiop[]asdfghjkl;\'zxcvbnm,./';
$count = isset($argv[1]) ? (int)$argv[1] : 1;
$needle = 'vb';
Timer::getInstance()->begin();
for($i = 0; $i < $count; $i++) {
 strtr($target, $needle, '*');
}
echo "strtr exec {$count} times used time: " . Timer::getInstance()->end()->gone() . " sec.\n";
//----------------------------------------------------------------------------------------------
Timer::getInstance()->begin();
for($i = 0; $i < $count; $i++) {
 str_replace($needle, '*', $target);
}
echo "str_replace exec {$count} times used time: " . Timer::getInstance()->end()->gone() . " sec.\n";

結(jié)果如下:

那個(gè)正則替換的那個(gè)就不測(cè)了,應(yīng)該是趕不上這兩個(gè)的。

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php常用函數(shù)與技巧總結(jié)》、《php字符串(string)用法總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP基本語(yǔ)法入門教程》、《php+mysql數(shù)據(jù)庫(kù)操作入門教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論