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:
I'm getting different results (within 10%) in MW Profiler every time I run my program.
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.
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 |
|---|---|---|
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.
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.
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().
My inline functions are not getting inlined when I'm profiling my code. What's happening?
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.
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.
While trying to profile my dynamically linked library (shared library), I get an error message saying that the profiling library could not be found.
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.
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.
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.
I see garbage names in MW Profiler on 68K (non-CFM) profile runs.
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.
Remove, or comment out, the calls to UnloadSeg() when profiling your code.