Static methods and performance

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();
?>

Bookmark and Share

Somewhat related posts

Leave a Reply