开发者

Assign a variable with list() [duplicate]

开发者 https://www.devze.com 2023-04-11 07:54 出处:网络
This question already has answers here: How can I measure the speed of code written in PHP? [closed] (10 answers)
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

精彩评论

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

关注公众号