开发者

Assign a variable with list() [duplicate]

This question already has answers here: How can I measure the speed of code written in PHP? [closed] (10 answers) Closed 1 year ago.

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";
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜