Jump to content

which is fastest?


Fyorl

Recommended Posts

I was just wondering if anyone was in a good position to test whether [code]func_num_args()[/code] is faster than [code]count(func_get_args())[/code]

(They come in very useful for creating functions with default values)
Anyway, I would assume the former as it's only one function call but I could be wrong as I don't know the inner workings of it.
Link to comment
https://forums.phpfreaks.com/topic/11445-which-is-fastest/
Share on other sites

I guess func_num_args() is faster. It's just a guess though.
You can test that by yourself, just time it like this:

[code]$time1 = microtime(true);
// Do method1 here
$time2 = microtime(true);
// Do method2 here
$time3 = microtime(true);

echo 'Method 1: ' . ($time2 - $time1);
echo 'Method 2: ' . ($time3 - $time2);[/code]
Link to comment
https://forums.phpfreaks.com/topic/11445-which-is-fastest/#findComment-42981
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.