<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Profiling functions</TITLE
|
>Profiling functions</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="Application profiling"
|
TITLE="Application profiling"
|
HREF="services-profile-gprof.html"><LINK
|
HREF="services-profile-gprof.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="Application profiling"
|
TITLE="Application profiling"
|
HREF="services-profile-gprof.html"><LINK
|
HREF="services-profile-gprof.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="eCos Power Management Support"
|
TITLE="eCos Power Management Support"
|
HREF="services-power.html"></HEAD
|
HREF="services-power.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="services-profile-gprof.html"
|
HREF="services-profile-gprof.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="services-power.html"
|
HREF="services-power.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
><H1
|
><H1
|
><A
|
><A
|
NAME="PROFILE-FUNCTIONS">Chapter 52. Profiling functions</H1
|
NAME="PROFILE-FUNCTIONS">Chapter 52. Profiling functions</H1
|
><DIV
|
><DIV
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><H1
|
><H1
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><A
|
><A
|
NAME="SERVICES-PROFILE-API">API</H1
|
NAME="SERVICES-PROFILE-API">API</H1
|
><P
|
><P
|
>In order for profile data to be gathered for an application, the
|
>In order for profile data to be gathered for an application, the
|
program has to initiate the process.
|
program has to initiate the process.
|
Once started, execution histogram data will be collected in a
|
Once started, execution histogram data will be collected in a
|
dynamic memory buffer.
|
dynamic memory buffer.
|
This data can be uploaded to a host using <SPAN
|
This data can be uploaded to a host using <SPAN
|
CLASS="emphasis"
|
CLASS="emphasis"
|
><I
|
><I
|
CLASS="EMPHASIS"
|
CLASS="EMPHASIS"
|
>TFTP</I
|
>TFTP</I
|
></SPAN
|
></SPAN
|
>.
|
>.
|
A side effect of the upload of the data is that the histogram
|
A side effect of the upload of the data is that the histogram
|
is reset.
|
is reset.
|
This is useful, especially for high resolution histograms, since
|
This is useful, especially for high resolution histograms, since
|
the histogram data are collected as 16-bit counters which can be quickly
|
the histogram data are collected as 16-bit counters which can be quickly
|
saturated.
|
saturated.
|
For example, if the histogram is being collected at a rate of 10,000
|
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
|
samples per second, a hot spot in the program could saturate after
|
only 6.5 seconds.</P
|
only 6.5 seconds.</P
|
><P
|
><P
|
> The API for the application profiling functions can be
|
> The API for the application profiling functions can be
|
found in the file <TT
|
found in the file <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
><cyg/profile/profile.h></TT
|
><cyg/profile/profile.h></TT
|
>.</P
|
>.</P
|
><DIV
|
><DIV
|
CLASS="SECT2"
|
CLASS="SECT2"
|
><H2
|
><H2
|
CLASS="SECT2"
|
CLASS="SECT2"
|
><A
|
><A
|
NAME="SERVICES-PROFILE-API-PROFILE-ON">profile_on</H2
|
NAME="SERVICES-PROFILE-API-PROFILE-ON">profile_on</H2
|
><P
|
><P
|
>This function is used to initiate the gathering of the
|
>This function is used to initiate the gathering of the
|
runtime execution histogram data.</P
|
runtime execution histogram data.</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
>void profile_on(void *start, void *end, int bucket_size, int resolution);</PRE
|
>void profile_on(void *start, void *end, int bucket_size, int resolution);</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>Calling this function will initiate execution profiling.
|
>Calling this function will initiate execution profiling.
|
An execution histogram is collected at the rate of
|
An execution histogram is collected at the rate of
|
<TT
|
<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>resolution</I
|
>resolution</I
|
></TT
|
></TT
|
> times per second.
|
> times per second.
|
The area between <TT
|
The area between <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>start</I
|
>start</I
|
></TT
|
></TT
|
> and <TT
|
> and <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>end</I
|
>end</I
|
></TT
|
></TT
|
>
|
>
|
will be divided up into a number of buckets, each representing
|
will be divided up into a number of buckets, each representing
|
<TT
|
<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>bucket_size</I
|
>bucket_size</I
|
></TT
|
></TT
|
>
|
>
|
program bytes in length. Using statistical sampling (via a high speed timer), when
|
program bytes in length. Using statistical sampling (via a high speed timer), when
|
the program counter is found to be within the range
|
the program counter is found to be within the range
|
<TT
|
<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>start</I
|
>start</I
|
></TT
|
></TT
|
>..<TT
|
>..<TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>end</I
|
>end</I
|
></TT
|
></TT
|
>, the appropriate
|
>, the appropriate
|
bucket (histogram entry) will be incremented.</P
|
bucket (histogram entry) will be incremented.</P
|
><P
|
><P
|
>The choice of <TT
|
>The choice of <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>resolution</I
|
>resolution</I
|
></TT
|
></TT
|
> and <TT
|
> and <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>bucket_size</I
|
>bucket_size</I
|
></TT
|
></TT
|
>
|
>
|
control how large the data gathered will be, as well as how much overhead is
|
control how large the data gathered will be, as well as how much overhead is
|
encumbered for gathering the histogram.
|
encumbered for gathering the histogram.
|
Smaller values for <TT
|
Smaller values for <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>bucket_size</I
|
>bucket_size</I
|
></TT
|
></TT
|
> will garner better
|
> will garner better
|
results (<TT
|
results (<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>gprof</TT
|
>gprof</TT
|
> can more closely align the data with
|
> can more closely align the data with
|
actual function names) at the expense of a larger data buffer.</P
|
actual function names) at the expense of a larger data buffer.</P
|
><DIV
|
><DIV
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><BLOCKQUOTE
|
><BLOCKQUOTE
|
CLASS="NOTE"
|
CLASS="NOTE"
|
><P
|
><P
|
><B
|
><B
|
>NOTE: </B
|
>NOTE: </B
|
>The value of <TT
|
>The value of <TT
|
CLASS="PARAMETER"
|
CLASS="PARAMETER"
|
><I
|
><I
|
>bucket_size</I
|
>bucket_size</I
|
></TT
|
></TT
|
> will be rounded up to a power of two.</P
|
> will be rounded up to a power of two.</P
|
></BLOCKQUOTE
|
></BLOCKQUOTE
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="services-profile-gprof.html"
|
HREF="services-profile-gprof.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="services-power.html"
|
HREF="services-power.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>Application profiling</TD
|
>Application profiling</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="services-profile-gprof.html"
|
HREF="services-profile-gprof.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>eCos Power Management Support</TD
|
>eCos Power Management Support</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|