When you design a program, the primary concern is how accurately and reliably it runs. Programs exist to perform some task, not to run in the shortest possible period of time. If the task cannot be completed, or completed inaccurately, then having it run fast is a waste of time. In addition, efficiency is a feature that can be added; accuracy is not. An accurate yet inefficient program can be optimized and made more efficient; the same is not true for an unreliable fast program. Inaccurate programs are useless, no matter how fast they run. Forget about how efficient a program is—unless—there is cause to be efficient. Program efficiency is vital in real-world applications, particularly in the context of speed and resources being consumed.
The problem with code today is that it runs too fast. Thirty years ago algorithms could be compared, and students got a feel for how different algorithms functioned – from the perspective of resources consumed and speed. This obviously had an impact on mid 1980s systems such PCs running the 80386 chip with a speed of 12-40 MHz, or the Apple Mac Plus at 8 MHz. You had to write somewhat efficient code or it would take *ages* to run. Okay, so now all machines are fast right, so who cares about optimization? Well machines are faster, but there is also way more data to contend with. A 1MP image takes way less time to process than a 20MP image. HD video takes a lot more power to stream. Inefficient algorithms eat more processor power which in turn eats more battery juice. It’s a vicious cycle. Consider this – you’re on summer holidays, the weather is hot, and the sky is kind-of hazy – not really conducive to taking great pictures. The solution of course is a filter that removes the haze from the image via post-processing on the camera. This is a great idea, but if the filter takes 1-2 minutes to run it will not be effective. If you run this off-camera it may be less of a deal, but a filter like this on camera should likely run in 5-10 seconds. It doesn’t matter how good the algorithm is, people want it to run in a reasonable time-frame.
inefficient algorithms ⇒ more processor time ⇒ battery drain ⇒ reduced mobile device battery life