Micro-optimisation¶
A micro-optimisation is a piece of code that performs better than another, yet brings only a small gain of speed.
Micro-optimisation should be done only for highly constraints systems, or application that deliver a high number of hits in short times : usually, it takes one to ten millions usage for the gain to be visible.
Yet, micro-optimisations may be valuable on the long run, or as a good practice.
It is often a pointless to discuss the micro-optimisation. It is a do or don’t, and should raise a consensus, or left alone.
<?php
// this is faster than calling 3 times echo
echo 1, 2, 3;
// This is slower, yet it doesn't speed up the process a lot
echo 1;
echo 2;
echo 3;
?>
See also 25 Easy PHP7 Micro-Optimizations, What are compiler optimized internal PHP functions and should you import them via use statement?