Ale*_*lex 9 php performance function
我有可能吗?例如.如果我想测试是否str_replace()更快preg_replace()?
str_replace()
preg_replace()
The*_*zoo 28
简单的方法:
$time = microtime(true); // time in Microseconds // Your code here echo (microtime(true) - $time) . ' elapsed';
硬(呃)方式:使用代码分析器确切地了解您的方法需要多长时间.
nop*_*ole 15
您可以在脚本中运行相同的行10,000次(或更多),并用它microtime(true)来告诉它花费的时间:
microtime(true)
microtime中()
Tin*_*ank 6
我在这个帖子中找到了'bisko'的答案.
$ start = microtime(true); for(...){....} $ end = microtime(true); echo($ end - $ start).' 秒;
$ start = microtime(true);
for(...){....}
$ end = microtime(true);
echo($ end - $ start).' 秒;
for循环可以替换为您想要的任何时间.
归档时间:
15 年 前
查看次数:
16660 次
最近记录:
6 年 前