When we have to return only one value parsed by sscanf / fscanf, should we assign a list of one variable or use optional assigned values?
E.G.
l开发者_Python百科ist($number) = fscanf($handle, "%d\n")
or
fscanf($handle, "%d\n", $number)
Is there any difference in execution speed of these expressions?
Just benchmark your two ways with a script like this:
<?php
function micro_time() {
$temp = explode(" ", microtime());
return bcadd($temp[0], $temp[1], 6);
}
$time_start = micro_time();
for ($i=0; $i<100; $i++) {
// the code you want to benchmark
}
$time_stop = micro_time();
$time_overall = bcsub($time_stop, $time_start, 6);
echo "Execution time - $time_overall Seconds";
?>
精彩评论