性能

来自tomtalk
跳转至: 导航搜索

PHP提高编程效率的方法

file_get_contents的超时处理

10个PHP高级应用技巧

一次php应用的优化实践

引用与传值,性能比较

$param = [
    'something', 'about', 'nothing',
    'something', 'about', 'nothing',
    'something', 'about', 'nothing',
    'something', 'about', 'nothing',
    'something', 'about', 'nothing'
];
$max = 10000;
$begin = time_ms();
 
for ($n = 0; $n < $max; $n++) {
    $this->ref($param);
}
 
$time_ref = time_ms();
echo '<p>ref: ' . ($time_ref - $begin);
 
for ($j = 0; $j < $max; $j++) {
    $this->val($param);
}
 
$time_val = time_ms();
echo '<p>val: ' . ($time_val - $time_ref);

输出:

ref: 36

val: 18

引用更耗时