Performance
From DocForge
Performance, in computing terms, is generally the speed at which a system can perform tasks. Performance can be measured subjectively by user perception or objectively with metrics.
[edit] Optimizing Performance
With computer systems comprising many different hardware and software components, there are many factors that affect overall performance. Metrics can be gathered to determine the slowest or most intensive sub-tasks. With this information bottlenecks can be found and analyzed, then improved or bypassed.
[edit] Software Performance
There are general best practices which help improve software performance.
- First run a profiler to locate portions of the code that run slowly, so that they can either be fixed or removed. The most efficient way to improve performance is to focus on those segments of an application that are the biggest bottlenecks. Finding those bottlenecks is the first step.
- Avoid highly repetitive tasks. Cache data which is time consuming to compute rather than computing it repeatedly. For example,
- A web application may cache some pages or parts of web pages rather than generate them dynamically on each request when the results will be identical.
- Cache relational database query results in memory if the query is "expensive" and will yield the same results each time. Some databases, such as MySQL, have this feature integrated.
- Avoid using the slowest hardware components where possible. For example, hard disk I/O is always far slower than memory, so retain short-term data in memory when possible. This leads to a common hardware-based performance improvement: increased RAM.
- Fail elegantly and avoid stalling on a bottleneck when possible. For example,
- Assume that network connections may disappear at any time so a user won't be forced to wait indefinitely if network data is unavailable.
- Implement short but reasonable timeouts which automatically expire if a resource does not respond.
- Build on top of frameworks and libraries which have already been tuned for performance.