[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

Chapter 7.

 

Troubleshooting



This chapter contains frequently asked questions (and answers) about the Profiler. If you have a problem with the profiler, come here first. Others may have encountered similar difficulties, and there may be a simple solution.

The general topics that are covered include:


Profile Times Vary Between Runs


Problem

I'm getting different results (within 10%) in MW Profiler every time I run my program.


Background

There are two potential reasons that this may be happening. Both are time-related problems. The first problem that can occur is inadequate time in the function relative to the profiler resolution. The second problem is clock resonance.


Inadequate time in the function

If the function time that you are trying to measure is only 10 times greater than the resolution of the timebase you are using, you'll have this problem.

The profiler uses these timebases:

 

Name
Resolution
Code
Ticks  
~16700 µs  
68K and PPC  
Time Manager  
~ 20 µs  
68K and PPC  
Microseconds  
~ 20 µs  
68K and PPC  


Solution

To solve this problem, increase the number of times your function is called, then the average the profiler computes will be more accurate.

Sometimes it is helpful to pull a routine out of a program, and into a special test program which calls it many times in a loop for performance tuning purposes. However, this technique is susceptible to cache differences between the test and real program.


Clock resonance

If the operations you are performing in your profiled code coincide with the incrementing of the profiler clock, the results can be distorted, and could show wild variations.


Solution

One way to avoid this problem is to increase the number of times your function is called.

Another way to avoid this problem is to increase the accuracy of the clock the profiler is using. You can only do this with the PowerPC profiler. The PowerPC profiler can use the RTC or TB registers of the PowerPC chip which have 128 ns or better resolution. Make a PowerPC version of your project and use bestTimeBase in your call to ProfilerInit().


Problems while Profiling Inline Functions


Problem

My inline functions are not getting inlined when I'm profiling my code. What's happening?


Background

When the compiler switch for profiling is turned on, the default setting for "don't inline functions" is changed to true. This is so that these functions will have profiling information collected for them.


Solution

Place a #pragma dont_inline off in your source file to turn on function inlining again. You will not collect profile information for inline functions. In effect, a function can be inlined or profiled, but not both. The profiler cannot profile an inlined function.


TIP

If you use the #pragma dont_inline off in your code, you may see profile results for some inline functions.
When you declare an inline function, the compiler is allowed, but not required to inline the function. It is perfectly legal for the compiler to inline some functions, but not others. Data is collected only for the calls that were not inlined. The calls that were inlined have their time added into the time of the calling function.



Profiling Library Could not be Found


Problem

While trying to profile my dynamically linked library (shared library), I get an error message saying that the profiling library could not be found.


Background

This problem occurs when trying to use the profiling library to profile your dynamically linked library and the profiling library is not in the search path.


Solution

Add the profiling library to the search path. If you are using the CodeWarrior IDE, see the CodeWarrior IDE User's Guide for information on search paths. If you are using MPW, see your MPW User's Manual.

ProfileLib is a shared library and should be in your Extensions folder. Make sure a path to the Extensions folder is set for your project.


Profiler and Virtual Memory

Profiling code with virtual memory or RAM Doubler active produces erratic and skewed result times. Make sure virtual memory or RAM Doubler are disabled when profiling your code.


TIP

It's actually best to turn off all extensions when performing a profile of your code. This will eliminate any chances of extension problems and background tasks skewing the profile results. Restart your computer with the Shift key held down to disable extensions.



Names are Garbled when Viewing a 68K Profile Dump


Problem

I see garbage names in MW Profiler on 68K (non-CFM) profile runs.


Background

You've left calls to UnloadSeg() in your program. Calls to UnloadSeg() in a 68K application cause serious problems for the profiler. The profiler maintains pointers to locations in the code. If you unload a segment that has profiled routines, that code is free to move around in memory, or be purged. At that time the profiler's internal pointers become invalid. This is the leading cause of corrupted profile data files.


Solution

Remove, or comment out, the calls to UnloadSeg() when profiling your code.

 


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 21, 2000