week12

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

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

View Full Document Right Arrow Icon
CS 177 Week 12: Running Time and Performance 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online