performance analysis and optimization. performance: time space power (cost) (weight) {development...

40
Performance Analysis and Optimization

Post on 20-Dec-2015

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

Performance Analysis and Optimization

Page 2: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

Performance:TimeSpacePower(cost)(weight){development time, ease of maintenance,

extensibility}

Note: 1. “big-O” analysis not sufficient here, we are dealing with specific physical sizes

2. notation “big-O” often really means Θ

Page 3: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

Arithmetic—basic algorithmsHierarchy of time complexity:

increment / decrementaddition / subtraction

multiplicationdivision / square root

other operations

can usually trade off time for spaceExample: addition of 2 16-bit numbers

carry-ripple adder: time - 31 gate delays space - 16 full adderscarry lookahead adder (4-bit units): time – 8 gate delays space – 4 4-bit CLA units—more gates, routing

Page 4: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_00

Example: summing array elements—linear in size of array

Page 5: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

table_14_00

How to analyze performance and Do optimizations

Page 6: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_01

Rates of growth for commonly encountered complexity:Asymptotic complexity

Page 7: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_02

Time complexity: loop

Page 8: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_03

How does this differ from previous example?

Page 9: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_04

While loop

Page 10: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_05

Nested loops—example:

Page 11: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_06

Time complexity of conditional statements:

Page 12: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_07

Linear search:

Page 13: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_08

Selection sort:

Page 14: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

Common data structures (not dynamic):

Array:

O(n) [move]:

Insert / delete at beginning

Insert / delete at end

Insert / delete in middle

O(1):

Access at beginning

Access at middle

Access at end

Page 15: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

Common data structures (not dynamic):Linked list:O(1):

Insert / delete at beginning access at beginning

O(n):insert / delete at end (or O(1) if extra pointer)insert / delete in middleAccess at middleAccess at end (or O(1) if extra pointer)

Page 16: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_09

Flow of control:sequential

Page 17: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_10

Loops/conditionals

Page 18: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_11

Example: loop

Page 19: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_12

Example: function call

Page 20: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_13

Code: C level

Page 21: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_14

Code: machine instruction set level

Page 22: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_16

If—2 levels

Page 23: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_18

While-2 levels

Page 24: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_19

Function call—machine level

Page 25: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_20

Function—C level

Page 26: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_21

What happens at machine level

Page 27: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_22

Function body– c level

Page 28: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_23

Function body—machine level

Page 29: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_24

Co-routines

Page 30: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_25

interrupts

Page 31: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_26

Response time—2 systems

Page 32: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_27

Best and worst case times

Page 33: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_28

Asynchronous events

Page 34: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_29

Memory: hierarchy / response times

Page 35: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

table_14_03

Power usage for some common operations

Page 36: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_30

Power—sophisticated management possible

Page 37: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_31

Using a power manager

Page 38: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_32

Power management schemes

Page 39: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

fig_14_33

Standard power modes

Page 40: Performance Analysis and Optimization. Performance: Time Space Power (cost) (weight) {development time, ease of maintenance, extensibility} Note: 1. “big-O”

table_14_02

Ways to analyze performance during development