Jump to content


Photo

which is fastest?


  • Please log in to reply
4 replies to this topic

#1 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 07 June 2006 - 09:32 PM

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

(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.
[table]



Don't worry, the printer fairies will sort it out.

#2 xyph

xyph
  • Staff Alumni
  • Advanced Member
  • 3,712 posts
  • LocationSurrey, BC

Posted 07 June 2006 - 09:36 PM

My guess would be in agreement with yours...

The 2nd function you're building an array simply to count it. Could be wrong though.

I doubt the difference in speed would be huge unless dealing with a very very large function.
Everything you need to know about storing user-names and passwords
http://www.openwall....Users-Passwords
Blank Page? Try forcing errors to display
ini_set('display_errors',1);
error_reporting(-1);

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 07 June 2006 - 10:13 PM

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

$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);

~ D Kuang

#4 xyph

xyph
  • Staff Alumni
  • Advanced Member
  • 3,712 posts
  • LocationSurrey, BC

Posted 07 June 2006 - 10:24 PM

Remember to do the testing on a large scale, otherwise the results will be useless.
Everything you need to know about storing user-names and passwords
http://www.openwall....Users-Passwords
Blank Page? Try forcing errors to display
ini_set('display_errors',1);
error_reporting(-1);

#5 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 08 June 2006 - 05:34 PM

Thanks guys, I've got a PHP 4 server and PHP 5 on my linux laptop so I'll do a test on there. Just one question, wouldn't testing on a 'large scale' involve passing many, many arguments to a function?
[table]



Don't worry, the printer fairies will sort it out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users