osProfileInit, osProfileStart, osProfileStop, osProfileFlush
Run time profile for text spaces without shared sources
#include <ultra64.h> /* ultra64.h */ void osProfileInit(OSProf *profp, u32 profcnt); void osProfileStart(u32 microseconds); void osProfileStop(void); void osProfileFlush(void);
Profiling provides CPU-use statistics by profiling the amount of CPU time expended by a program in disjoint text spaces.
Profiling generates the statistics by creating an execution histogram for a current process. The histogram is defined for a list of regions of program code to be profiled specified by members of the profp array: profp[0], profp[1], ..., profp[profcnt-1]. The host-side application gperf copies the histogram data to the host and prints a report detailing the relative time spent processing each function.
The OSProf data structure has the following elements:
Each OSprof entry specifies a region of text space that needs to be profiled. If an instruction falls outside the bounds specified by the profp array, an internal 32-bit overflow counter is incremented.
The osProfileInit function initializes the profiled segment count buffers and starts an IO thread that communicates profile data to the host when requested by the gperf tool. To use it, pass a pointer to an array of OSProf structures (profp) each element of which describes a segment to be profiled. The profcnt argument indicates the number of profiled segments. The osProfileInit function clears the counters for each profiled segment. A thread is started to service requests for profile data from the gperf tool. Profiling data can be dumped to the host any time after osProfileInit is called. Call osProfileInit before calling any other profiler function.
The osProfileStart function is called to start the profiler's interval counter. The microseconds argument sets the period of this timer; A typical value is 10000 microseconds (10 milliseconds). The minimum timer period is defined by PROF_MIN_INTERVAL. Each time an interrupt is generated by the counter, the profiler determines which profiled segment the PC belongs to and then increments the proper counter in the counter buffer for that segment. If the PC does not lie within any profiled segment, an internal overflow register is incremented. There is no protection for counter overflow.
The osProfileStop function is called to turn off profiling. Profiling data remains in memory but is not incremented further. The thread started by osProfileInit to send profile data to the host continues to run. You can call it again to resume profiling.
The osProfileFlush function can be used to programmatically transfer profile data to the gperf program assuming the gperf program is running in server mode. gperf program can also send requests to the profiler's IO thread at any time while the program is executing in non-server mode.
The following errors are reported when you are using the debug library:
osProfileInit, osProfileStart, osProfileStop, gperf, and makerom
1999/04/30 Changed format