week12

# week12 - Week 12 Running Time and Performance CS 177 1 How...

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

CS 177 Week 12: Running Time and Performance 1

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

View Full Document
How long does a program take to run? Most of the problems you have written in this class run in a few seconds or less Some kinds of programs can take much longer: Chess algorithms (Deep Blue) Routing and scheduling algorithms (Traveling Sales Person, Purdue classroom scheduling) Medical imaging (massive amounts of data) Graphics processing (Pixar: Toy Story, 2
How can you measure the amount of time a program takes? You can time the program What if it takes 1000 years to run? You can look at the program What are you looking for? Does the input matter? Sorting 100,000 numbers must take longer than sorting 10 numbers, right? 3

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

View Full Document
Algorithms A sequence of steps used to solve a problem In CS, we take an algorithm and convert it into code -- Java in this class The study of algorithms is intended to: Make sure that the code you write gets the right answer Make sure that the code runs as quickly as possible 4
Algorithmic example: search You want to find the definition of the word “rheostat” in the dictionary The Oxford English Dictionary has 301,100 main entries What if you search for the word “rheostat” by starting at the beginning and checking each word to see if it is the one we are interested in Given a random word, you’ll have to 5

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

View Full Document
Algorithmic example: Summation Write a program to sum up the numbers between 1 and n Easy, right? Let us recall that a faster way might be to use the summation equation: = + = n i n n i 1 2 ) 1 ( 6
Memory usage Memory usage is a problem too If you run out of memory, your program can crash Memory usage can have serious performance consequences too 7

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

View Full Document
Memory Remember, there are multiple levels of memory on a computer Each next level is on the order of 100 times larger and 100 times slower 100X 100X 100X 100X Size Speed 8
Memory speed If you can do a lot of number crunching without leaving cache, that will be very fast If you have to fetch data from RAM, that will slow things down If you have to read and write data to the hard drive (unavoidable with large pieces of data like digital movies), you will slow things down a lot 9

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.

## This note was uploaded on 02/23/2012 for the course CS 177 taught by Professor Staff during the Spring '08 term at Purdue.

### Page1 / 35

week12 - Week 12 Running Time and Performance CS 177 1 How...

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

View Full Document
Ask a homework question - tutors are online