Performance of static methods vs. functions

前端 未结 7 795
盖世英雄少女心
盖世英雄少女心 2020-11-29 21:50

In PHP, (unlike what I originally thought) there is an overhead of calling static methods vs simple functions.

On a very simple bench, the overhead is over 30% of th

7条回答
  •  时光说笑
    2020-11-29 22:50

    In the case of the static method, PHP has to check wether the method can or cannot be called from the calling context (public, protected, private). That's most likely what causes the overhead, or at least part of it, since the classic function call doesn't require PHP to perform that kind of check.

提交回复
热议问题