Title: Why Does Performance Analysis Matter?
1Why Does Performance
Analysis Matter?
Check out the table of time complexity functions!
2Comparison of Time Complexity Functions
10 20 30 40 50 60
n .00001second .00002second .00003second .00004second .00005second .00006second
n2 .0001second .0004second .0009second .0016second .0025second .0036second
n3 .001second .008second .027second .064second .125second .216second
n5 .1second 3.2seconds 24.3seconds 1.7minutes 5.2minutes 13.0minutes
2n .001second 1.0second 17.9minutes 12.7days 35.7years 366centuries
3n .059second 58minutes 6.5years 3855centuries 2x108centuries 1.3x1013centuries
3Timings of Insert
4Timings of Change Phase
5Timings of Extract
6Total Timings
7Example A Messy Timing Function
- Based on
- using the Sorting_Machine to sort n items
- selection sort used to implement the
Sorting_Machine - tsel-sort(n) c1 n c2 c3 n (n1)/2
8Simplify with Big-Oh Notation
- Used to simplify the description of timing
functions - DefinitionLet f integer?0 ? integer?0.
Then,O(f) t integer?0 ? integer?0 where
there are constants c gt 0 and
m ? 0 such that t(n) ? c f(n) for
all n ? m - When t is in O(f), we say t is O(f)
9What Does t is O(f) Mean?
y
y 2f(n)
yt(n)
yf(n)
n
m
10Big-Oh Continued
- Is tsel-sort in O(n2)?
- Is tsel-sort in O(n3)?
- Is tsel-sort in O(n)?
- Is tsel-sort in O(n log2(n))?
11Some Important Timing
Functions
- constant time c
- log time c log n
- linear time c n
- n-log-n time c n log n
- quadratic time c n2
12Growth of Common Functions
2n
n3
n2
n logn
n
logn
c
13Big-Oh Example Comparisons
of Running Times
Poor AlgorithmO(n2) Poor AlgorithmO(n2) BetterAlgorithmO(n logn)
Size ofProblem GoodImplement. PoorImplement. ?
n T(n)5n2 ms T(n)10n2 ms T(n)50 n logn ms
10 .0005 sec. .001 sec. .002 sec.
100 .05 sec. .1 sec. .03 sec.
1,000 5 sec. 10 sec. .5 sec.
10,000 8 min. 16 min. 6.6 sec.
100,000 14 hours 28 hours 83 sec.
1,000,000 58 days 116 days 17 min.