Chapter 52. profiling functions, Profileon, Profiling functions – Comtrol eCos User Manual
Page 653: Profile_on

Chapter 52. Profiling functions
API
In order for profile data to be gathered for an application, the program has to initiate the process. Once started,
execution histogram data will be collected in a dynamic memory buffer. This data can be uploaded to a host using
TFTP. A side effect of the upload of the data is that the histogram is reset. This is useful, especially for high
resolution histograms, since the histogram data are collected as 16-bit counters which can be quickly saturated. For
example, if the histogram is being collected at a rate of 10,000 samples per second, a hot spot in the program could
saturate after only 6.5 seconds.
The API for the application profiling functions can be found in the file
<
cyg/profile/profile.h
>
.
profile_on
This function is used to initiate the gathering of the runtime execution histogram data.
void profile_on(void *start, void *end, int bucket_size, int resolution);
Calling this function will initiate execution profiling. An execution histogram is collected at the rate of
reso-
lution
times per second. The area between
start
and
end
will be divided up into a number of buckets, each
representing
bucket_size
program bytes in length. Using statistical sampling (via a high speed timer), when
the program counter is found to be within the range
start
..
end
, the appropriate bucket (histogram entry) will be
incremented.
The choice of
resolution
and
bucket_size
control how large the data gathered will be, as well as how
much overhead is encumbered for gathering the histogram. Smaller values for
bucket_size
will garner better
results (
gprof
can more closely align the data with actual function names) at the expense of a larger data buffer.
NOTE: The value of
bucket_size
will be rounded up to a power of two.
549