| CompOrg Fall 2002 Homework #6 FAQ | ||
| CompOrg Home | Syllabus | HW6 Description | ||
| Question: | I'm using the fixed gprof and libgmon.a, but I still get funny results when running substr. |
| Answer: | You should be able to get gprof to report on time/call, (but total time for the program will be wrong). Just use these times in your report, the total time for the program is not something you need to know to write the report. If you aren't happy doing this, just write up your proposed modifications to substr and discuss what you expect to happen in broad terms (will it become 2x faster, 10x faster, 100 x faster, ...?) |
|   |   |
| Question: | gcc doesn't seem to create the gmon.out file the gprof wants, what should I do? |
| Answer: | You actually need to run your program! If you compile with -pg, your program will create gmon.out when you run the program. If you change the program and recompile it, you need to re-run the program (to create a new gmon.out). |
|   |   |
| Question: | I can't make SIZE large enough to force the transpose function to take very long. If SIZE is too large I get a SEGV, what should I do? |
| Answer: | There are limitations on the size of a single data structure when running on a PC, so you can't expect to be able to use SIZE=10000 The idea of using gprof is to have your function called many times, rather than just calling it once. Try using SIZE=100 and call transpose 10,000 times (works fine for me). |
|   |   |
| Question: | Yet more on Cygwin gprof |
| Answer: | If you are having problems with Cygwin gprof, you can
download a new version of cp /usr/lib/libgmon.a /usr/lib/libgmin.a.old cp libgmon.a /usr/lib/libgmon.a cp /usr/bin/gprof.exe /usr/bin/gprof.exe.old cp gprof.exe /usr/bin/gprof.exe Once you do this you need to recompile and rerun your programs before you will get gprof to work for you... On a Thinkpad T22 under Cygwin I get the following output from
gprof when I run Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 70.00 0.07 0.07 500 0.14 0.14 substr 20.00 0.09 0.02 500 0.04 0.04 substr1 10.00 0.10 0.01 strlen 0.00 0.10 0.00 1 0.00 90.00 test substr is the unmodified function, substr1 is one that has some obvious changes made to it (it is a lot faster!). |
|   |   |
| Question: | Cygwin issues |
| Answer: | Cygwin gprof won't compute the number of calls or time/call (no matter what kind of function you measure). In addition, if your function spends most of it's time in a library function, gprof may not report any correct numbers for time. Your options are:
|
|   |   |
| Question: | I can't make any measurements of the |
| Answer: | gprof for Cygwin seems to have trouble measuring functions that spend most of their time calling library functions. If you make give substr large enough strings (increasing the string size should increase the total time spent in the function), you can get totals printed for substr (total time spent in the function) and use this to compute the time/call yourself. Note that gprof on Linux doesn't have this problem, I am able to get reasonable results as long as I make sure substr takes a while (this was demonstrated in class when we played with various string length functions). I am looking to see if there is a better solution for Cygwin, so far it does not appear that there will be anything to make profiling work better for functions that don't do much other than call other functions... |
|   |   |