CS320: Performance Evaluation Plotting data sets Semi log plots - - PowerPoint PPT Presentation

cs320 performance evaluation plotting data sets semi log
SMART_READER_LITE
LIVE PREVIEW

CS320: Performance Evaluation Plotting data sets Semi log plots - - PowerPoint PPT Presentation

CS320: Performance Evaluation Plotting data sets Semi log plots Log log plots Analyzing Program Performance In Computer Science, we plot functions describing the run time (or the memory use) of a program a s a function of the input size. We


slide-1
SLIDE 1

CS320: Performance Evaluation Plotting data sets Semi log plots Log log plots

slide-2
SLIDE 2

Analyzing Program Performance

In Computer Science, we plot functions describing the run time (or the memory use) of a program as a function of

the input size. We run a program for a number of input sizes and end up with performance data sets. We want to characterize these as an order of magnitude, e.g. O(n2) or O(2n) complexity, i.e., we want to look at a plot and establish its O growth behavior. Let’s look at some examples.

slide-3
SLIDE 3

Example: 3 data sets f, g and h

What kinds of functions are f, g and h?

0" 20" 40" 60" 80" 100" 120" 140" 160" 180" 1" 2" 3" 4" 5" f" g" h"

n f(n) g(n) h(n)

1

2 9 2

2

12 18 6

3

36 35 24

4

80 68 68

5

150 131 162

Hard / impossible to infer

  • exponential? which base?
  • polynomial? which degree?

WHY?

slide-4
SLIDE 4

Why are functions hard to infer?

Two problems:

¨Very small domain (here 1..5)

n Try to get a large data domain

¨Interpreting polynomial and exponential functions

from plots is hard, they all just swoop up

slide-5
SLIDE 5

Larger domain

0" 2000" 4000" 6000" 8000" 10000" 12000" 14000" 16000" 18000" 0" 2" 4" 6" 8" 10" 12" 14" f" g" h"

n f(n) g(n) h(n)

1

2 9 2

2

12 18 6

3

36 35 24

4

80 68 68

5

150 131 162

7

400 520 624

10

1100 4106 2510

12

1872 16396 5196 Notice that values for n=1-5 are practically on the floor now, and we see different behavior further on. The steeper a plot, the higher its Order of Magnitude.

slide-6
SLIDE 6

Larger domain

0" 2000" 4000" 6000" 8000" 10000" 12000" 14000" 16000" 18000" 0" 2" 4" 6" 8" 10" 12" 14" f" g" h"

n f(n) g(n) h(n)

1

2 9 2

2

12 18 6

3

36 35 24

4

80 68 68

5

150 131 162

7

400 520 624

10

1100 4106 2510

12

1872 16396 5196 Which function may be polynomial, which exponential? Still, not all clear (order, base…), h(n) may spike up later…

slide-7
SLIDE 7

Straight Lines

We get the most information from straight lines!

¨ We can easily recognize a straight line (y = ax+b)

n The slope (a) and y intercept (b) tells us all.

¨ So we need to turn our data sets into straight lines. ¨ This is easiest done using log-s, because they turn an

exponential into a multiplicative factor, and a multiplicative factor into a shift.

log an = n log a log a*n = log a + log n

slide-8
SLIDE 8

Exponential functions

n log(2n) = n log2 linear in n

log(3n) = n log3 the log(base) of the exponential becomes the multiplicative constant and determines the slope in the plot

n log(4*3n) = n log3 + log4 linear, same slope

log((3n)/4) = n log3 – log4 but *4 or /4 shifts the plot up or down

slide-9
SLIDE 9

Exponentials: semi log plot

n 2n 3n 20*3n

1 1 20 1 2 3 60 2 4 9 180 3 8 27 540 4 16 81 1620 5 32 243 4860 7 128 2087 41740 10 1024 56349 1126980

1" 10" 100" 1000" 10000" 100000" 1000000" 10000000" 0" 2" 4" 6" 8" 10" 12" 2^n" 3^n" 20"3^n"

Semi log plot: y–axis on log scale x-axis linear slope: log base shift: multiplicative factor

slide-10
SLIDE 10

Polynomials

n What if we take the log of a polynomial?

e.g. f(n) = 5n3 log(f(n)) = log(5n3) = log5 + 3 log(n) not a straight line!

n But the log of a polynomial is linear in log(n) n Therefore we need to plot polynomials on a

log log scale (both x and y axis logarithmic)

slide-11
SLIDE 11

Polynomials: log-log plot

n n2 n3 20*n3

1 1 1 20 2 4 8 160 4 16 64 1280 8 64 512 10240 16 256 4096 81820 32 1024 32768 655360 slope: degree shift: multiplicative factor

1" 10" 100" 1000" 10000" 100000" 1000000" 1" 10" 100" n^2" n^3" 20"n^3"

slide-12
SLIDE 12

Example

Plot data:

1,64 2,128 3,256 4,512 5,1024 6,2048 7,4096 8,8192

linear linear log log semi log Semi log plot makes a straight line

slide-13
SLIDE 13

Example continued

Plot data:

1,64 2,128 3,256 4,512 5,1024 6,2048 7,4096 8,8192

semi log

Semi log plot makes a straight line. Therefore we have exponential data. slope: (13-6)/(8-1)=1 log2 base = 1, therefore base = 2log base = 21 = 2