lec10

# lec10 - 10 • Algorithm analysis vs measurement • Timing...

This preview shows pages 1–7. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 10 • Algorithm analysis vs. measurement • Timing an algorithm • Average and standard deviation • Improving measurement accuracy CSE 12 Algorithm Time Cost Measurement 06-2/19 Introduction • Three characteristics of programs are of interest: – robustness : a program’s ability to spot exceptional conditions and deal with them or shutdown gracefully – correctness : does the program do what it is “supposed to” do? – efficiency : all programs use resources (time, space, and energy); how can we measure efficiency so that we can compare algorithms? Analysis and Measurement An algorithm’s performance can be described by: – time complexity or cost – how long it takes to execute. In general, less time is better! – space complexity or cost – how much computer memory it uses. In general, less space is better! – energy complexity or cost – how much energy uses. In general, less energy is better! • Costs are usually given as functions of the size of the input to the algorithm • A big instance of the problem will probably take more resources to solve than a small one, but how much more? 06-4/19 Figuring algorithm costs • For a given algorithm, we would like to know the following as functions of n , the size of the problem: • T( n ) , the time cost of solving the problem • S( n ) , the space cost of solving the problem • E( n ) , the energy cost of solving the problem • Two approaches: – We can analyze the written algorithm – Or we could implement the algorithm and run it and measure the time, memory, and energy usage 06-5/19 Algorithm analysis vs. measurement • Asymptotic analysis (counting statements executed, and writing the result as a simple function using big-O, big-omega, or big-theta notation) is elegant, and it's important to know how to do it... but it is an abstraction that doesn’t tell the full story. • As just one example: in terms of asymptotic analysis of time cost, finding the largest value in an array of int s and an array of Integer objects is the same, but in reality… • So it can be important also to consider algorithm measurement , also known as benchmarking 06-6/19 Algorithm Measurement The basic idea is simple: – Implement the algorithm – Measure the time, space, or energy it takes for the implementation to run, on inputs of different sizes – Plot the measurements and characterize T(...
View Full Document

## This note was uploaded on 03/27/2012 for the course CSE 12 taught by Professor Gary during the Fall '08 term at UCSD.

### Page1 / 24

lec10 - 10 • Algorithm analysis vs measurement • Timing...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online