In this case the branch unit begins fetching at the

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: 6 3.19 12.75 0.0008 0.0016 131,072 51.01 0.0031 262,144 186.71 0.0060 Figure 5.8: Comparative Performance of Lower-Case Conversion Routines. The original code lower1 has quadratic asymptotic complexity due to an inefficient loop structure. The modified code lower2 has linear complexity. 216 CHAPTER 5. OPTIMIZING PROGRAM PERFORMANCE entirely possible that the procedure could be applied to a string of one million characters, for which lower1 would over require nearly one hour of CPU time. All of a sudden this benign piece of code has become a major performance bottleneck. By contrast, lower2 would complete in well under one second. Stories abound of major programming projects in which problems of this sort occur. Part of the job of a competent programmer is to avoid ever introducing such asymptotic inefficiency. Practice Problem 5.2: Consider the following functions: int min(int x, int y) { return x < y ? x : y; } int max(int x, int y) { return x < y ? y : x; } void incr(int *xp, int v) {...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online