Content deleted Content added
m →top: grammar in short description |
Citation bot (talk | contribs) Add: s2cid. Removed proxy/dead URL that duplicated identifier. | Use this bot. Report bugs. | Suggested by Abductive | Category:Software optimization | #UCB_Category 8/61 |
||
Line 56:
===Platform dependent and independent optimizations===
Code optimization can be also broadly categorized as [[computer platform|platform]]-dependent and platform-independent techniques. While the latter ones are effective on most or all platforms, platform-dependent techniques use specific properties of one platform, or rely on parameters depending on the single platform or even on the single processor. Writing or producing different versions of the same code for different processors might therefore be needed. For instance, in the case of compile-level optimization, platform-independent techniques are generic techniques (such as [[loop unwinding|loop unrolling]], reduction in function calls, memory efficient routines, reduction in conditions, etc.), that impact most CPU architectures in a similar way. A great example of platform-independent optimization has been shown with inner for loop, where it was observed that a loop with an inner for loop performs more computations per unit time than a loop without it or one with an inner while loop.<ref>{{Cite journal|last=Adewumi|first=Tosin P.|date=2018-08-01|title=Inner loop program construct: A faster way for program execution
==Strength reduction==
Line 103:
[[Donald Knuth]] made the following two statements on optimization:
<blockquote>"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%"<ref name="autogenerated268">{{cite journal | last = Knuth | first = Donald | citeseerx = 10.1.1.103.6084 | title = Structured Programming with go to Statements | journal = ACM Computing Surveys | volume = 6 | issue = 4 |date=December 1974 | page = 268 | doi = 10.1145/356635.356640 | s2cid = 207630080 }}</ref></blockquote>
:(He also attributed the quote to [[Tony Hoare]] several years later,<ref>''The Errors of [[TeX]]'', in ''Software—Practice & Experience'', Volume 19, Issue 7 (July 1989), pp. 607–685, reprinted in his book Literate Programming (p. 276).</ref> although this might have been an error as Hoare disclaims having coined the phrase.<ref><!--Tony Hoare, a 2004 email-->{{Cite web|title=Premature optimization is the root of all evil|url=https://hans.gerwitz.com/2004/08/12/premature-optimization-is-the-root-of-all-evil.html|access-date=2020-12-18|quote=Hoare, however, did not claim it when I queried him in January of 2004|website=hans.gerwitz.com|language=en}}</ref>)
<blockquote> "In established engineering disciplines a 12% improvement, easily obtained, is never considered marginal and I believe the same viewpoint should prevail in software engineering"<ref name="autogenerated268"/></blockquote>
Line 136:
Optimization can be automated by compilers or performed by programmers. Gains are usually limited for local optimization, and larger for global optimizations. Usually, the most powerful optimization is to find a superior [[algorithm]].
Optimizing a whole system is usually undertaken by programmers because it is too complex for automated optimizers. In this situation, programmers or system administrators explicitly change code so that the overall system performs better. Although it can produce better efficiency, it is far more expensive than automated optimizations. Since many parameters influence the program performance, the program optimization space is large. Meta-heuristics and machine learning are used to address the complexity of program optimization.<ref>{{cite journal|last1=Memeti|first1=Suejb|last2=Pllana|first2=Sabri|last3=Binotto|first3=Alécio|last4=Kołodziej|first4=Joanna|last5=Brandic|author5-link= Ivona Brandić |first5=Ivona|title=Using meta-heuristics and machine learning for software optimization of parallel computing systems: a systematic literature review|journal=Computing|volume=101|issue=8|pages=893–936|date=26 April 2018|doi=10.1007/s00607-018-0614-9|publisher=Springer Vienna|arxiv=1801.09444|bibcode=2018arXiv180109444M|s2cid=13868111}}</ref>
Use a [[Profiler (computer science)|profiler]] (or [[Profiling (computer programming)|performance analyzer]]) to find the sections of the program that are taking the most resources{{snd}} the ''bottleneck''. Programmers sometimes believe they have a clear idea of where the bottleneck is, but intuition is frequently wrong.{{citation needed|date=May 2012}} Optimizing an unimportant piece of code will typically do little to help the overall performance.
|