Static methods and performance

March 28th, 2005. Tagged: PHP certification

How fast/slow are the static methods?
I did a test once to try and figure that out.

It turns out:

  • Calling a method statically is just a bit faster than calling it "normally"
  • Calling a static method is twice as fast if your object didn't exist to begin with
  • Static methods are twice as slow than function calls

By calling statically I mean:
< ?php Some_Class::someMethod(); ?>
An calling "normally" is when you create an object and call the method using ->
< ?php $sc = new Some_Class(); $sc->someMethod();

Tell your friends about this post on Facebook and Twitter

Sorry, comments disabled and hidden due to excessive spam.

Meanwhile, hit me up on twitter @stoyanstefanov