An abstract version of the function has a cpe of 54

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: g. With GCC (and other C compilers) this involves simply including the run-time flag ‘-pg’ on the command line: unix> gcc -O2 -pg prog.c -o prog 2. The program is then executed as usual: unix> ./prog file.txt It runs slightly (up to a factor of two) slower than normal, but otherwise the only difference is that it generates a file gmon.out. 262 CHAPTER 5. OPTIMIZING PROGRAM PERFORMANCE 3. G PROF is invoked to analyze the data in gmon.out. unix> gprof prog The first part of the profile report lists the times spent executing the different functions, sorted in descending order. As an example, the following shows this part of the report for the first three functions in a program: % cumulative time seconds 85.62 7.80 6.59 8.40 4.50 8.81 self seconds 7.80 0.60 0.41 self ms/call 7800.00 0.00 0.00 total ms/call 7800.00 0.00 0.00 calls 1 946596 946596 name sort_words find_ele_rec lower1 Each row represents the time spent for all calls to some function. The first column indicates the percentage of the overall time spent on the function. The second shows the cumulative time spent by the function...
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