Performance of Singleton Class Instance Method vs. Static Class Method in PHP?

前端 未结 5 1502
天涯浪人
天涯浪人 2021-02-06 12:06

I\'m interested in objective analysis of which is more performant; calling instance methods of a singleton class or methods of a static class. I\'ve already seen this so I\'m no

5条回答
  •  忘了有多久
    2021-02-06 12:34

    Unless you're calling them in a tight loop (meaning no other significant code, where the overhead of the call is significant) thousands or hundreds of thousands of times, don't worry about it. The difference is likely going to be under a microsecond, so it's not worth fretting over. Simply make the best architectural choice...

    Premature optimization is the root of all evil...

    Edit: To all the downvoters, here's a blog post that I wrote that describes why performance comparisons like this are all but useless.

提交回复
热议问题