DEV Community

Discussion on: Optimizing your PHP app speed

Collapse
 
darkain profile image
Vincent Milum Jr

About that last point, it truly is a "micro-optimization", in that, odds are there are other areas that are in the orders of hundreds to thousands of times more CPU intensive within the code that could be optimized using better overall application logic. Micro-optimizations are things we put in that we think will make a difference that really don't in the grand scheme of things.

Measuring the impact of having the leading slash or not results in ~1-8ms better performance across one-million executions. With such a minor difference in performance, a developer's time would honestly be better spent on more significant portions of the application.

3v4l.org/QaY2t

Collapse
 
darkain profile image
Vincent Milum Jr

Doing further investigating, it is actually MORE impactful to not use namespaces at all. If you are not actively within a namespace, and you don't use the leading \, then you get even more "micro-optimization" out of your code! ;)

3v4l.org/tmJMq