Performance of static methods vs. functions

前端 未结 7 792
盖世英雄少女心
盖世英雄少女心 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:47

    Apparently this point has been fixed in later versions of PHP (5.5.12).

    I ran the OP's code (with empty methods), and I get these results :

    Static Time:   1.0153820514679 ms
    Object Time:   1.100515127182 ms
    

    Edit: Eight months and some releases later...

    It's interesting to see how Zend and the community are working hard on PHP's performance.

提交回复
热议问题