我怎么能说哪一类(哪些都做同样的工作)执行得更快?有没有可以衡量的软件?
如果我使用相对路径作为参数,是否有任何性能优势file_get_contents()?
file_get_contents("../../mypage.php");
V/S
file_get_contents("http://.../mypage.php");
file_get_contents()内部如何处理?
在性能方面,哪个更好?
在对象中:
情况1
public function test( $array ) {
return array_map( array( $this, 'do_something_to_element' ), $array );
}
Run Code Online (Sandbox Code Playgroud)
案例#2
public function test( $array ) {
$return = array();
foreach ( $array as $value ) {
$return[] = do_something_to_element( $value );
}
return $return;
}
Run Code Online (Sandbox Code Playgroud)
当然还有其他用途,可以填充许多例子.我已经看到注释,在一个对象中,array_map比foreach循环慢.
一般来说,array_map/array_walk的执行速度比类似需求的foreach循环更快吗?