📄 profile-functions.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>Profiling functions</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="Application profiling"HREF="services-profile-gprof.html"><LINKREL="PREVIOUS"TITLE="Application profiling"HREF="services-profile-gprof.html"><LINKREL="NEXT"TITLE="eCos Power Management Support"HREF="services-power.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="services-profile-gprof.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="services-power.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="PROFILE-FUNCTIONS">Chapter 52. Profiling functions</H1><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="SERVICES-PROFILE-API">API</H1><P>In order for profile data to be gathered for an application, theprogram has to initiate the process.Once started, execution histogram data will be collected in adynamic memory buffer.This data can be uploaded to a host using <SPANCLASS="emphasis"><ICLASS="EMPHASIS">TFTP</I></SPAN>.A side effect of the upload of the data is that the histogramis reset.This is useful, especially for high resolution histograms, sincethe histogram data are collected as 16-bit counters which can be quicklysaturated.For example, if the histogram is being collected at a rate of 10,000samples per second, a hot spot in the program could saturate afteronly 6.5 seconds.</P><P> The API for the application profiling functions can befound in the file <TTCLASS="FILENAME"><cyg/profile/profile.h></TT>.</P><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="SERVICES-PROFILE-API-PROFILE-ON">profile_on</H2><P>This function is used to initiate the gathering of theruntime execution histogram data.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void profile_on(void *start, void *end, int bucket_size, int resolution);</PRE></TD></TR></TABLE><P>Calling this function will initiate execution profiling.An execution histogram is collected at the rate of<TTCLASS="PARAMETER"><I>resolution</I></TT> times per second.The area between <TTCLASS="PARAMETER"><I>start</I></TT> and <TTCLASS="PARAMETER"><I>end</I></TT>will be divided up into a number of buckets, each representing <TTCLASS="PARAMETER"><I>bucket_size</I></TT> program bytes in length. Using statistical sampling (via a high speed timer), whenthe program counter is found to be within the range <TTCLASS="PARAMETER"><I>start</I></TT>..<TTCLASS="PARAMETER"><I>end</I></TT>, the appropriatebucket (histogram entry) will be incremented.</P><P>The choice of <TTCLASS="PARAMETER"><I>resolution</I></TT> and <TTCLASS="PARAMETER"><I>bucket_size</I></TT>control how large the data gathered will be, as well as how much overhead is encumbered for gathering the histogram.Smaller values for <TTCLASS="PARAMETER"><I>bucket_size</I></TT> will garner betterresults (<TTCLASS="FUNCTION">gprof</TT> can more closely align the data withactual function names) at the expense of a larger data buffer.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>NOTE: </B>The value of <TTCLASS="PARAMETER"><I>bucket_size</I></TT> will be rounded up to a power of two.</P></BLOCKQUOTE></DIV></DIV></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="services-profile-gprof.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="services-power.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Application profiling</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="services-profile-gprof.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">eCos Power Management Support</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -