Performance Tuning Techinques.

原创 2004年10月22日 22:25:00

Logic
1. Stop testing when you know the answer.
Some languages provides a form of expression evaluation known as "short-circuit evaluation", which means that the compiler generates code that automatically stops testing as soon as it knows the answer. If your language doesn't support short-circuit evaluation natively, you have to aovid using 'and' and 'or'.
The principle is a good one for many other kinds of cases as well. A search loop is a common case. For example, you're scanning an array of input numbers to find out a negative value.
 a. Add a break statement after the negative value is found.
 b. If your language doesn't have break, emulate a break with a goto that goes to the first  statement after the loop.
 c. Change the for loop to a while loop.
2. Order tests by frequency.
Arrange tests so that the one that's fastest and most likely to be true is performed first. This principle applies to case statements and to chains of if-then-elses.
3. Compare performance of similar logic structures.
Language          case          if-then-else          Performance Ration
C#                0.260             0.330                    1:1
Java              2.56              0.450                    6:1
Visual Basic      0.260             1.00                     1:4
4. Substitute table lookups for complicated
In some circumstances, a table lookup may be quicker than traversing a complicated chain of logic. The detailed informaction please refer to "Table-Driven Methods"
5. Use lazy evaluation.
Lazy evaluation is similar to just-in-time strategies that do the work closest to when it's needed.

Loops
1. Unswitching
Switching refers to making a decision inside a loop every time it's executed. If the decision doesn't change while the loop is executing, you can unswitch the loop by making the decision outside the loop. Usually this requires turning the loop inside out, putting loops inside the conditional rather than putting the conditional inside the loop.
2. Jamming
Jamming, or "fusion", is the result of combining two loops that operate on the same set of elements.
Loop jamming has two main hazards. First the indexes for the two parts that have been jammed might change so that they are no longer compatible. Second, you might not be able to combine the loops easily.
3. Unrolling.
The goal of loop unrolling is to reduce the amount of loop housekeeping. Although completely unrolling a loop is a fast solution and works well when you're dealing with a small number of elements, it's not practical when you have a large number of elements or when you don't know in advance how many elements you'll have.
4. Minimizing the work inside loops
One key to writing effective loops is to minimize the work done inside a loop.
5. Sentinel values.
When you have a loop with a compound test, you can often save time by simplifying the test. If the loop is a search loop, one way to simplify the test is to use a sentinel value, a value that you put just past the end of the search range and that's guaranteed to terminate the search.
6. Putting the busiest loop on the inside.
When you have nested loops, think about which loop you want on the outside and which you want on the inside.
7. Strength reduction.
Reducing strength means replaceing an expensive operation such as multiplication with a cheaper operation such as addition.

Data Transformations
1. Use integers rather than floating-point numbjers.
2. Use the fewest array dimensions possible.
3. Minimize array references.
4. Use supplementary indexes.
5. Use caching.

Expressions
1. Exploit algebraic identities, for example: not a and not b=not (a or b), but if you choose the second one instead of the first one, you can save a not operation.
2. Use strength reduction.
 a. Replace multiplication with addition.
 b. Replace exponentiation with multiplication.
 c. Replace trigonometric routines with their trigonometric identities.
 d. Replace longlong integers with longs or ints.
 e. Replace floating-point numbers with fixed-point numbers or integers.
 f. Replace double-precision floating with single-precision numbers.
 g. Replace integer multiplication-by-two and division-by-two with shift operations.
3. Initialize at complie time.
4. Be wary of system routines.
5. Use the correct types of constants.
6. Precompute results.
If the results are used many times, it's often cheaper to compute them once and look them up the rest of the time.
7. Eliminate common subexpressions.
If you find a expression that's repeated several tiems, assign it to a variable and refer to the variable rather than recomputing the expression in several places.

Oracle Performance Tuning Overview 翻译(Oracle性能优化概述 自己的中英文比对翻译)

Oracle® Database Performance Tuning Guide 10g Release 2 (10.2) B14211-03 Home Book List ...
  • xiaohai798
  • xiaohai798
  • 2014年06月23日 23:26
  • 2752

Performance Tuning Guide

文中注释处以符号"*"加章节数字标记,具体在章节最后统一详细说明。 chapter 6  Automatic performance diagnostics Sql语句中尽量不要直接使用具体变量值进行...
  • battlehawk
  • battlehawk
  • 2010年04月10日 21:16
  • 672

WebSphere Application Server Performance Tuning Toolkit

WebSphere® Application Server Performance Tuning Toolkit 是一款基于 Eclipse 的智能工具,旨在帮助用户通过使用数据收集、数据分析和统计数...
  • Angel_He
  • Angel_He
  • 2014年08月30日 22:30
  • 1228

ORACLE SQL Performance Tuning

Oracle Database上的设置对Performance的影响很大,如Shared Pool Size、Buffer Cache Size、SGA Structures、Database I/O...
  • cunxiyuan108
  • cunxiyuan108
  • 2012年04月19日 00:23
  • 843

OCP-1Z0-053-V12.02-407题

407.Which of the following is a potential performance tuning recommendation from the SQL Access Advi...
  • rlhua
  • rlhua
  • 2013年11月03日 10:18
  • 4062

websphere出了个性能调优工具toolkit

IBM has released the WebSphere Application Server Performance Tuning Toolkit that gives the ability ...
  • jackyrongvip
  • jackyrongvip
  • 2013年07月01日 17:52
  • 1081

Tuning NGINX for Performance nginx性能调优

from: http://nginx.com/blog/tuning-nginx/ NGINX is well known as a high performance load balanc...
  • longxibendi
  • longxibendi
  • 2015年06月29日 18:11
  • 1030

performance tuning for linux

http://www.cyberciti.biz/faq/linux-tcp-tuning/ http://bradhedlund.com/2008/12/19/how-to-calculate-tc...
  • RichardYSteven
  • RichardYSteven
  • 2011年11月29日 17:37
  • 635

Java Performance Tuning笔记

pdf在这里: http://mfinocchiaro.files.wordpress.com/2008/07/java-virtual-machine-neutral.pdf 以及关于gc的官方文档...
  • jollyjumper
  • jollyjumper
  • 2014年03月02日 19:14
  • 1732

Oracle Wait Interface: A Practical Guide to Performance Diagnostics & Tuning

Oracle Wait Interface性能诊断与调整实践指南(比较薄但比较实用) 
  • llmmysun
  • llmmysun
  • 2006年04月17日 14:09
  • 1485
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Performance Tuning Techinques.
举报原因:
原因补充:

(最多只允许输入30个字)