性能
来自tomtalk
引用与传值,性能比较
$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
引用更耗时