|
In computer science, efficiency is used to describe several desirable properties of an algorithm or other construct, besides clean design, functionality, etc. Efficiency is generally contained in two properties: speed (the time it takes for an operation to complete), and space (the memory or non-volatile storage used up by the construct). Optimization is the process of making code as efficient as possible, sometimes focusing on space at the cost of speed, or vice versa. Computer scaence, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ...
In mathematics, computing, linguistics, and related disciplines, an algorithm is a finite list of well-defined instructions for accomplishing some task that, given an initial state, will terminate in a defined end-state. ...
In computing, optimization is the process of modifying a system to make some aspect of it work more efficiently or use fewer resources. ...
The speed of an algorithm is measured in various ways. The most common method uses time complexity to determine the Big-O of an algorithm: often, it is possible to make an algorithm faster at the expense of space. This is the case whenever you cache the result of an expensive calculation rather than recalculating it on demand. This is a very common method of improving speed, so much so that languages often add special features to support it, such as C++'s mutable keyword. Complexity theory is part of the theory of computation dealing with the resources required during computation to solve a given problem. ...
Big O notation or Big Oh notation, and also Landau notation or asymptotic notation, is a mathematical notation used to describe the asymptotic behavior of functions. ...
C++ (pronounced see plus plus, IPA: ) is a general-purpose, high-level programming language with low-level facilities. ...
The space of an algorithm is actually two separate but related things. The first part is the space taken up by the compiled executable on disk (or equivalent, depending on the hardware and language) by the algorithm. This can often be reduced by preferring run-time decision making mechanisms (such as virtual functions and run-time type information) over certain compile-time decision making mechanisms (such as macro substitution and templates). This, however, comes at the cost of speed. In object-oriented programming (OOP), a virtual function or virtual method is a function whose behavior, by virtue of being declared virtual, is determined by the definition of a function with the same signature furthest in the inheritance lineage of the instantiated object on which it is called. ...
In programming, Runtime Type Information (RTTI, RunTime Type Identification) means keeping information about an objects datatype in memory at runtime. ...
A macro in computer science is an abstraction, whereby a certain textual pattern is replaced according to a defined set of rules. ...
In computer programming, templates are a feature of the C++ programming language that allow code to be written without consideration of the data type with which it will eventually be used. ...
The other part of algorithm space measurement is the amount of temporary memory taken up during processing. For example, pre-caching results, as mentioned earlier, improves speed at the cost of this attribute. Optimization of algorithms frequently depends on the properties of the machine the algorithm will be executed on. For example, one might optimize code for time efficiency in applications for home computers with sizable amounts of memory, while code to be placed in small, memory-tight devices may have to be made to run slower to conserve space. One simple way to determine whether an optimization is worthwhile is as follows: Let the original time and space requirements (generally in Big-O notation) of the algorithm be O1 and O2. Let the new code require N1 and N2 time and space respectively. If N1N2 < O1O2, the optimization should be carried out. However, as mentioned above, this may not always be true. One must be careful, in the pursuit of good coding style, not to over-emphasize efficiency. Nearly all of the time, a clean and usable design is much more important than a fast, small design. There are exceptions to this rule (such as embedded systems, where space is tight, and processing power minimal) but these are rarer than one might expect. It has been suggested that Embedded System Design in an FPGA be merged into this article or section. ...
See also
|