Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > e7618febbb9cbed15bb79e326774c050 > files > 224

ompl-devel-0.9.5-1.fc14.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8"/>
<title>OMPL: src/ompl/util/Profiler.h Source File</title>
<meta name="author" content="Ioan A. Șucan, Mark Moll, Lydia E. Kavraki">
<link rel="stylesheet" href="../css/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print">
<!--[if lt IE 7]>
<script type="text/javascript" src="../js/jquery/jquery.js"></script>
<script type="text/javascript" src="../js/jquery/jquery.dropdown.js"></script>
<![endif]-->
<script type="text/javaScript" src="search/search.js"></script>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-9156598-2']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search API');
--></script>
<div class="navigation" id="top">
  <div class="tabs" id="ompltitle">
    <ul class="tablist">
      <li>The Open Motion Planning Library</li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search API" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)"
               onblur="searchBox.OnSearchFieldFocus(false)"
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>

  <ul id="nav" class="dropdown">
    <li class="first"><a href="index.html">Home</a></li>
    <li><a href="download.html">Download</a></li>
    <li><a href="documentation.html">Documentation</a></li>
    <li><span class="dir">Code API</span>
      <ul>
        <li><a href="api_overview.html">API Overview</a></li>
        <li><a href="namespaces.html">Namespaces</a></li>
        <li><a href="annotated.html">Classes</a></li>
        <li><a href="files.html">Files</a></li>
        <li><a href="dirs.html">Directories</a></li>
      </ul>
    </li>
    <li><span class="dir">Community</span>
      <ul>
        <li><a href="developers.html">Developers</a></li>
        <li><a href="thirdparty.html">Contributions</a></li>
        <li><a href="education.html">Education</a></li>
        <li><a href="gallery.html">Gallery</a></li>
      </ul>
    </li>
    <li><span class="dir">About</span>
      <ul>
        <li><a href="license.html">License</a></li>
        <li><a href="citations.html">Citations</a></li>
        <li><a href="acknowledgements.html">Acknowledgments</a></li>
        <li><a href="contact.html">Contact Us</a></li>
      </ul>
    </li>
  </ul>
</div>

<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
  onmouseover="return searchBox.OnSearchSelectShow()"
  onmouseout="return searchBox.OnSearchSelectHide()"
  onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
  <iframe src="" frameborder="0"name="MSearchResults" id="MSearchResults"></iframe>
</div>

<div class="container">
  <div class="span-22 push-2 first last">
  <div>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="dir_f5421e52a658cd938113ed6044324834.html">src</a>      </li>
      <li class="navelem"><a class="el" href="dir_ae92c2ff78847f0cb49b545f9089bbbc.html">ompl</a>      </li>
      <li class="navelem"><a class="el" href="dir_37166c801688e2f0df3874113410995a.html">util</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Profiler.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*********************************************************************</span>
<a name="l00002"></a>00002 <span class="comment">* Software License Agreement (BSD License)</span>
<a name="l00003"></a>00003 <span class="comment">*</span>
<a name="l00004"></a>00004 <span class="comment">*  Copyright (c) 2008, Willow Garage, Inc.</span>
<a name="l00005"></a>00005 <span class="comment">*  All rights reserved.</span>
<a name="l00006"></a>00006 <span class="comment">*</span>
<a name="l00007"></a>00007 <span class="comment">*  Redistribution and use in source and binary forms, with or without</span>
<a name="l00008"></a>00008 <span class="comment">*  modification, are permitted provided that the following conditions</span>
<a name="l00009"></a>00009 <span class="comment">*  are met:</span>
<a name="l00010"></a>00010 <span class="comment">*</span>
<a name="l00011"></a>00011 <span class="comment">*   * Redistributions of source code must retain the above copyright</span>
<a name="l00012"></a>00012 <span class="comment">*     notice, this list of conditions and the following disclaimer.</span>
<a name="l00013"></a>00013 <span class="comment">*   * Redistributions in binary form must reproduce the above</span>
<a name="l00014"></a>00014 <span class="comment">*     copyright notice, this list of conditions and the following</span>
<a name="l00015"></a>00015 <span class="comment">*     disclaimer in the documentation and/or other materials provided</span>
<a name="l00016"></a>00016 <span class="comment">*     with the distribution.</span>
<a name="l00017"></a>00017 <span class="comment">*   * Neither the name of the Willow Garage nor the names of its</span>
<a name="l00018"></a>00018 <span class="comment">*     contributors may be used to endorse or promote products derived</span>
<a name="l00019"></a>00019 <span class="comment">*     from this software without specific prior written permission.</span>
<a name="l00020"></a>00020 <span class="comment">*</span>
<a name="l00021"></a>00021 <span class="comment">*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00022"></a>00022 <span class="comment">*  &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00023"></a>00023 <span class="comment">*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS</span>
<a name="l00024"></a>00024 <span class="comment">*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE</span>
<a name="l00025"></a>00025 <span class="comment">*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,</span>
<a name="l00026"></a>00026 <span class="comment">*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,</span>
<a name="l00027"></a>00027 <span class="comment">*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span>
<a name="l00028"></a>00028 <span class="comment">*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER</span>
<a name="l00029"></a>00029 <span class="comment">*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span>
<a name="l00030"></a>00030 <span class="comment">*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN</span>
<a name="l00031"></a>00031 <span class="comment">*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span>
<a name="l00032"></a>00032 <span class="comment">*  POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00033"></a>00033 <span class="comment">*********************************************************************/</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="comment">/* Author Ioan Sucan */</span>
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="preprocessor">#ifndef OMPL_UTIL_PROFILER_</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#define OMPL_UTIL_PROFILER_</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>
<a name="l00041"></a>00041 <span class="preprocessor">#define ENABLE_PROFILING 1</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>
<a name="l00043"></a>00043 <span class="preprocessor">#ifndef ENABLE_PROFILING</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00048"></a>00048 <span class="preprocessor">#  ifdef NDEBUG</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span><span class="preprocessor">#    define ENABLE_PROFILING 0</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#  else</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span><span class="preprocessor">#    define ENABLE_PROFILING 1</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor">#  endif</span>
<a name="l00053"></a>00053 <span class="preprocessor"></span>
<a name="l00054"></a>00054 <span class="preprocessor">#endif</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span>
<a name="l00056"></a>00056 <span class="preprocessor">#if ENABLE_PROFILING</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span>
<a name="l00058"></a>00058 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00059"></a>00059 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include &lt;boost/thread.hpp&gt;</span>
<a name="l00062"></a>00062 <span class="preprocessor">#include &lt;boost/noncopyable.hpp&gt;</span>
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 <span class="preprocessor">#include &quot;ompl/util/Time.h&quot;</span>
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 <span class="keyword">namespace </span>ompl
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068 
<a name="l00075"></a><a class="code" href="classompl_1_1Profiler.html">00075</a>     <span class="keyword">class </span><a class="code" href="classompl_1_1Profiler.html" title="This is a simple thread-safe tool for counting time spent in various chunks of code. This is different from external profiling tools in that it allows the user to count time spent in various bits of code (sub-function granularity) or count how many times certain pieces of code are executed.">Profiler</a> : <span class="keyword">private</span> boost::noncopyable
<a name="l00076"></a>00076     {
<a name="l00077"></a>00077     <span class="keyword">public</span>:
<a name="l00078"></a>00078 
<a name="l00080"></a><a class="code" href="classompl_1_1Profiler_1_1BeginBlock.html">00080</a>         <span class="keyword">class </span><a class="code" href="classompl_1_1Profiler_1_1BeginBlock.html" title="This instance will call Profiler::begin() when constructed and Profiler::end() when it goes out of sc...">BeginBlock</a>
<a name="l00081"></a>00081         {
<a name="l00082"></a>00082         <span class="keyword">public</span>:
<a name="l00083"></a>00083 
<a name="l00084"></a>00084             <a class="code" href="classompl_1_1Profiler_1_1BeginBlock.html" title="This instance will call Profiler::begin() when constructed and Profiler::end() when it goes out of sc...">BeginBlock</a>(<span class="keyword">const</span> std::string &amp;name, <a class="code" href="classompl_1_1Profiler.html" title="This is a simple thread-safe tool for counting time spent in various chunks of code. This is different from external profiling tools in that it allows the user to count time spent in various bits of code (sub-function granularity) or count how many times certain pieces of code are executed.">Profiler</a> &amp;prof = <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Profiler::Instance</a>()) : name_(name), prof_(prof)
<a name="l00085"></a>00085             {
<a name="l00086"></a>00086                 prof_.<a class="code" href="classompl_1_1Profiler.html#a5f1e59ea058ea5ba30fb3e52b3d892d7" title="Begin counting time for a specific chunk of code.">begin</a>(name);
<a name="l00087"></a>00087             }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089             ~<a class="code" href="classompl_1_1Profiler_1_1BeginBlock.html" title="This instance will call Profiler::begin() when constructed and Profiler::end() when it goes out of sc...">BeginBlock</a>(<span class="keywordtype">void</span>)
<a name="l00090"></a>00090             {
<a name="l00091"></a>00091                 prof_.<a class="code" href="classompl_1_1Profiler.html#add3c74cb47a2f76c0f517d702301a17d" title="Stop counting time for a specific chunk of code.">end</a>(name_);
<a name="l00092"></a>00092             }
<a name="l00093"></a>00093 
<a name="l00094"></a>00094         <span class="keyword">private</span>:
<a name="l00095"></a>00095 
<a name="l00096"></a>00096             std::string  name_;
<a name="l00097"></a>00097             <a class="code" href="classompl_1_1Profiler.html" title="This is a simple thread-safe tool for counting time spent in various chunks of code. This is different from external profiling tools in that it allows the user to count time spent in various bits of code (sub-function granularity) or count how many times certain pieces of code are executed.">Profiler</a>    &amp;prof_;
<a name="l00098"></a>00098         };
<a name="l00099"></a>00099 
<a name="l00101"></a>00101         <span class="keyword">static</span> <a class="code" href="classompl_1_1Profiler.html" title="This is a simple thread-safe tool for counting time spent in various chunks of code. This is different from external profiling tools in that it allows the user to count time spent in various bits of code (sub-function granularity) or count how many times certain pieces of code are executed.">Profiler</a>&amp; <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>(<span class="keywordtype">void</span>);
<a name="l00102"></a>00102 
<a name="l00105"></a><a class="code" href="classompl_1_1Profiler.html#ab03aeab6be531dc043d4b5e49e76cd13">00105</a>         <a class="code" href="classompl_1_1Profiler.html#ab03aeab6be531dc043d4b5e49e76cd13" title="Constructor. It is allowed to separately instantiate this class (not only as a singleton)">Profiler</a>(<span class="keywordtype">bool</span> printOnDestroy = <span class="keyword">false</span>, <span class="keywordtype">bool</span> autoStart = <span class="keyword">false</span>) : running_(false), printOnDestroy_(printOnDestroy)
<a name="l00106"></a>00106         {
<a name="l00107"></a>00107             <span class="keywordflow">if</span> (autoStart)
<a name="l00108"></a>00108                 <a class="code" href="classompl_1_1Profiler.html#a33c953ccc35f5de9d1e5de5737a3b6b2" title="Start counting time.">start</a>();
<a name="l00109"></a>00109         }
<a name="l00110"></a>00110 
<a name="l00112"></a><a class="code" href="classompl_1_1Profiler.html#ab5b736004260ed82114c7eb160787065">00112</a>         <a class="code" href="classompl_1_1Profiler.html#ab5b736004260ed82114c7eb160787065" title="Destructor.">~Profiler</a>(<span class="keywordtype">void</span>)
<a name="l00113"></a>00113         {
<a name="l00114"></a>00114             <span class="keywordflow">if</span> (printOnDestroy_ &amp;&amp; !data_.empty())
<a name="l00115"></a>00115                 <a class="code" href="classompl_1_1Profiler.html#a0945496c0f8e90149ca58e0c6e217ca9" title="Print the status of the profiled code chunks and events to the console (using msg::Console)">console</a>();
<a name="l00116"></a>00116         }
<a name="l00117"></a>00117 
<a name="l00119"></a><a class="code" href="classompl_1_1Profiler.html#ae73e60be58f1e1289bb421eb5ed60341">00119</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#ae73e60be58f1e1289bb421eb5ed60341" title="Start counting time.">Start</a>(<span class="keywordtype">void</span>)
<a name="l00120"></a>00120         {
<a name="l00121"></a>00121             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#a33c953ccc35f5de9d1e5de5737a3b6b2" title="Start counting time.">start</a>();
<a name="l00122"></a>00122         }
<a name="l00123"></a>00123 
<a name="l00125"></a><a class="code" href="classompl_1_1Profiler.html#adae56178a52fd8c78d7e833208087691">00125</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#adae56178a52fd8c78d7e833208087691" title="Stop counting time.">Stop</a>(<span class="keywordtype">void</span>)
<a name="l00126"></a>00126         {
<a name="l00127"></a>00127             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#a9bf75e95615aa61dfa2b07cb33de41f6" title="Stop counting time.">stop</a>();
<a name="l00128"></a>00128         }
<a name="l00129"></a>00129 
<a name="l00131"></a><a class="code" href="classompl_1_1Profiler.html#a641450af19cefdaab88ae2e6c716ca78">00131</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a641450af19cefdaab88ae2e6c716ca78" title="Clear counted time and events.">Clear</a>(<span class="keywordtype">void</span>)
<a name="l00132"></a>00132         {
<a name="l00133"></a>00133             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#a392d62f749d11465c641df65363a476d" title="Clear counted time and events.">clear</a>();
<a name="l00134"></a>00134         }
<a name="l00135"></a>00135 
<a name="l00137"></a>00137         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a33c953ccc35f5de9d1e5de5737a3b6b2" title="Start counting time.">start</a>(<span class="keywordtype">void</span>);
<a name="l00138"></a>00138 
<a name="l00140"></a>00140         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a9bf75e95615aa61dfa2b07cb33de41f6" title="Stop counting time.">stop</a>(<span class="keywordtype">void</span>);
<a name="l00141"></a>00141 
<a name="l00143"></a>00143         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a392d62f749d11465c641df65363a476d" title="Clear counted time and events.">clear</a>(<span class="keywordtype">void</span>);
<a name="l00144"></a>00144 
<a name="l00146"></a><a class="code" href="classompl_1_1Profiler.html#a39fca9814de79fb9c2ce06ea819b24b6">00146</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a39fca9814de79fb9c2ce06ea819b24b6" title="Count a specific event for a number of times.">Event</a>(<span class="keyword">const</span> std::string&amp; name, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> times = 1)
<a name="l00147"></a>00147         {
<a name="l00148"></a>00148             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#a5d76f125e73929ee850a0bac41e5cd95" title="Count a specific event for a number of times.">event</a>(name, times);
<a name="l00149"></a>00149         }
<a name="l00150"></a>00150 
<a name="l00152"></a>00152         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a5d76f125e73929ee850a0bac41e5cd95" title="Count a specific event for a number of times.">event</a>(<span class="keyword">const</span> std::string &amp;name, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> times = 1);
<a name="l00153"></a>00153 
<a name="l00155"></a><a class="code" href="classompl_1_1Profiler.html#a7bc2411a6a4dc7aa289e421e2f688812">00155</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a7bc2411a6a4dc7aa289e421e2f688812" title="Begin counting time for a specific chunk of code.">Begin</a>(<span class="keyword">const</span> std::string &amp;name)
<a name="l00156"></a>00156         {
<a name="l00157"></a>00157             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#a5f1e59ea058ea5ba30fb3e52b3d892d7" title="Begin counting time for a specific chunk of code.">begin</a>(name);
<a name="l00158"></a>00158         }
<a name="l00159"></a>00159 
<a name="l00161"></a><a class="code" href="classompl_1_1Profiler.html#a276b67abbea043be27684fd1be96bca1">00161</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a276b67abbea043be27684fd1be96bca1" title="Stop counting time for a specific chunk of code.">End</a>(<span class="keyword">const</span> std::string &amp;name)
<a name="l00162"></a>00162         {
<a name="l00163"></a>00163             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#add3c74cb47a2f76c0f517d702301a17d" title="Stop counting time for a specific chunk of code.">end</a>(name);
<a name="l00164"></a>00164         }
<a name="l00165"></a>00165 
<a name="l00167"></a>00167         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a5f1e59ea058ea5ba30fb3e52b3d892d7" title="Begin counting time for a specific chunk of code.">begin</a>(<span class="keyword">const</span> std::string &amp;name);
<a name="l00168"></a>00168 
<a name="l00170"></a>00170         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#add3c74cb47a2f76c0f517d702301a17d" title="Stop counting time for a specific chunk of code.">end</a>(<span class="keyword">const</span> std::string &amp;name);
<a name="l00171"></a>00171 
<a name="l00175"></a><a class="code" href="classompl_1_1Profiler.html#aeabfce91f1acc251c86c1a99518323a5">00175</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#aeabfce91f1acc251c86c1a99518323a5" title="Print the status of the profiled code chunks and events. Optionally, computation done by different th...">Status</a>(std::ostream &amp;out = std::cout, <span class="keywordtype">bool</span> merge = <span class="keyword">true</span>)
<a name="l00176"></a>00176         {
<a name="l00177"></a>00177             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#a286f3f6f33e494a8babf262bf58162bb" title="Print the status of the profiled code chunks and events. Optionally, computation done by different th...">status</a>(out, merge);
<a name="l00178"></a>00178         }
<a name="l00179"></a>00179 
<a name="l00183"></a>00183         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a286f3f6f33e494a8babf262bf58162bb" title="Print the status of the profiled code chunks and events. Optionally, computation done by different th...">status</a>(std::ostream &amp;out = std::cout, <span class="keywordtype">bool</span> merge = <span class="keyword">true</span>);
<a name="l00184"></a>00184 
<a name="l00187"></a><a class="code" href="classompl_1_1Profiler.html#a89f18caea7a4952776304db50a135102">00187</a>         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a89f18caea7a4952776304db50a135102" title="Print the status of the profiled code chunks and events to the console (using msg::Console)">Console</a>(<span class="keywordtype">void</span>)
<a name="l00188"></a>00188         {
<a name="l00189"></a>00189             <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>().<a class="code" href="classompl_1_1Profiler.html#a0945496c0f8e90149ca58e0c6e217ca9" title="Print the status of the profiled code chunks and events to the console (using msg::Console)">console</a>();
<a name="l00190"></a>00190         }
<a name="l00191"></a>00191 
<a name="l00194"></a>00194         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a0945496c0f8e90149ca58e0c6e217ca9" title="Print the status of the profiled code chunks and events to the console (using msg::Console)">console</a>(<span class="keywordtype">void</span>);
<a name="l00195"></a>00195 
<a name="l00196"></a>00196     <span class="keyword">private</span>:
<a name="l00197"></a>00197 
<a name="l00199"></a>00199         <span class="keyword">struct </span>TimeInfo
<a name="l00200"></a>00200         {
<a name="l00201"></a>00201             TimeInfo(<span class="keywordtype">void</span>) : total(0, 0, 0, 0), shortest(boost::posix_time::pos_infin), longest(boost::posix_time::neg_infin), parts(0)
<a name="l00202"></a>00202             {
<a name="l00203"></a>00203             }
<a name="l00204"></a>00204 
<a name="l00206"></a>00206             <a class="code" href="namespaceompl_1_1time.html#a4c9f24d26cae91eb6598630f6a22e1b9" title="Representation of a time duration.">time::duration</a>    total;
<a name="l00207"></a>00207 
<a name="l00209"></a>00209             <a class="code" href="namespaceompl_1_1time.html#a4c9f24d26cae91eb6598630f6a22e1b9" title="Representation of a time duration.">time::duration</a>    shortest;
<a name="l00210"></a>00210 
<a name="l00212"></a>00212             <a class="code" href="namespaceompl_1_1time.html#a4c9f24d26cae91eb6598630f6a22e1b9" title="Representation of a time duration.">time::duration</a>    longest;
<a name="l00213"></a>00213 
<a name="l00215"></a>00215             <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> parts;
<a name="l00216"></a>00216 
<a name="l00218"></a>00218             <a class="code" href="namespaceompl_1_1time.html#a9f28e947d7e95cfa5f0790ccdb7f0953" title="Representation of a point in time.">time::point</a>       <a class="code" href="classompl_1_1Profiler.html#a33c953ccc35f5de9d1e5de5737a3b6b2" title="Start counting time.">start</a>;
<a name="l00219"></a>00219 
<a name="l00221"></a>00221             <span class="keywordtype">void</span> <span class="keyword">set</span>(void)
<a name="l00222"></a>00222             {
<a name="l00223"></a>00223                 <a class="code" href="classompl_1_1Profiler.html#a33c953ccc35f5de9d1e5de5737a3b6b2" title="Start counting time.">start</a> = <a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>();
<a name="l00224"></a>00224             }
<a name="l00225"></a>00225 
<a name="l00227"></a>00227             <span class="keywordtype">void</span> update(<span class="keywordtype">void</span>)
<a name="l00228"></a>00228             {
<a name="l00229"></a>00229                 <span class="keyword">const</span> <a class="code" href="namespaceompl_1_1time.html#a4c9f24d26cae91eb6598630f6a22e1b9" title="Representation of a time duration.">time::duration</a> &amp;dt = <a class="code" href="namespaceompl_1_1time.html#a1413ad6c9709d0699343679b291b9c1d" title="Get the current time point.">time::now</a>() - <a class="code" href="classompl_1_1Profiler.html#a33c953ccc35f5de9d1e5de5737a3b6b2" title="Start counting time.">start</a>;
<a name="l00230"></a>00230                 <span class="keywordflow">if</span> (dt &gt; longest)
<a name="l00231"></a>00231                     longest = dt;
<a name="l00232"></a>00232                 <span class="keywordflow">if</span> (dt &lt; shortest)
<a name="l00233"></a>00233                     shortest = dt;
<a name="l00234"></a>00234                 total = total + dt;
<a name="l00235"></a>00235                 ++parts;
<a name="l00236"></a>00236             }
<a name="l00237"></a>00237         };
<a name="l00238"></a>00238 
<a name="l00240"></a>00240         <span class="keyword">struct </span>PerThread
<a name="l00241"></a>00241         {
<a name="l00243"></a>00243             std::map&lt;std::string, unsigned long int&gt; events;
<a name="l00244"></a>00244 
<a name="l00246"></a>00246             std::map&lt;std::string, TimeInfo&gt;          time;
<a name="l00247"></a>00247         };
<a name="l00248"></a>00248 
<a name="l00249"></a>00249         <span class="keywordtype">void</span> printThreadInfo(std::ostream &amp;out, <span class="keyword">const</span> PerThread &amp;data);
<a name="l00250"></a>00250 
<a name="l00251"></a>00251         boost::mutex                           lock_;
<a name="l00252"></a>00252         std::map&lt;boost::thread::id, PerThread&gt; data_;
<a name="l00253"></a>00253         TimeInfo                               tinfo_;
<a name="l00254"></a>00254         <span class="keywordtype">bool</span>                                   running_;
<a name="l00255"></a>00255         <span class="keywordtype">bool</span>                                   printOnDestroy_;
<a name="l00256"></a>00256 
<a name="l00257"></a>00257     };
<a name="l00258"></a>00258 }
<a name="l00259"></a>00259 
<a name="l00260"></a>00260 <span class="preprocessor">#else</span>
<a name="l00261"></a>00261 <span class="preprocessor"></span>
<a name="l00262"></a>00262 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00263"></a>00263 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00264"></a>00264 
<a name="l00265"></a>00265 <span class="comment">/* If profiling is disabled, provide empty implementations for the</span>
<a name="l00266"></a>00266 <span class="comment">   public functions */</span>
<a name="l00267"></a>00267 <span class="keyword">namespace </span>ompl
<a name="l00268"></a>00268 {
<a name="l00269"></a>00269 
<a name="l00270"></a>00270     <span class="keyword">class </span>Profiler
<a name="l00271"></a>00271     {
<a name="l00272"></a>00272     <span class="keyword">public</span>:
<a name="l00273"></a>00273 
<a name="l00274"></a>00274         <span class="keyword">class </span>BeginBlock
<a name="l00275"></a>00275         {
<a name="l00276"></a>00276         <span class="keyword">public</span>:
<a name="l00277"></a>00277 
<a name="l00278"></a>00278             BeginBlock(<span class="keyword">const</span> std::string &amp;, <a class="code" href="classompl_1_1Profiler.html#ab03aeab6be531dc043d4b5e49e76cd13" title="Constructor. It is allowed to separately instantiate this class (not only as a singleton)">Profiler</a> &amp; = <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Profiler::Instance</a>())
<a name="l00279"></a>00279             {
<a name="l00280"></a>00280             }
<a name="l00281"></a>00281 
<a name="l00282"></a>00282             ~BeginBlock(<span class="keywordtype">void</span>)
<a name="l00283"></a>00283             {
<a name="l00284"></a>00284             }
<a name="l00285"></a>00285         };
<a name="l00286"></a>00286 
<a name="l00287"></a>00287         <span class="keyword">static</span> <a class="code" href="classompl_1_1Profiler.html#ab03aeab6be531dc043d4b5e49e76cd13" title="Constructor. It is allowed to separately instantiate this class (not only as a singleton)">Profiler</a>&amp; <a class="code" href="classompl_1_1Profiler.html#a4d04876139e9b5e91b74c9d6bfe12de8" title="Return an instance of the class.">Instance</a>(<span class="keywordtype">void</span>);
<a name="l00288"></a>00288 
<a name="l00289"></a>00289         <a class="code" href="classompl_1_1Profiler.html#ab03aeab6be531dc043d4b5e49e76cd13" title="Constructor. It is allowed to separately instantiate this class (not only as a singleton)">Profiler</a>(<span class="keywordtype">bool</span> = <span class="keyword">true</span>, <span class="keywordtype">bool</span> = <span class="keyword">true</span>)
<a name="l00290"></a>00290         {
<a name="l00291"></a>00291         }
<a name="l00292"></a>00292 
<a name="l00293"></a>00293         <a class="code" href="classompl_1_1Profiler.html#ab5b736004260ed82114c7eb160787065" title="Destructor.">~Profiler</a>(<span class="keywordtype">void</span>)
<a name="l00294"></a>00294         {
<a name="l00295"></a>00295         }
<a name="l00296"></a>00296 
<a name="l00297"></a>00297         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#ae73e60be58f1e1289bb421eb5ed60341" title="Start counting time.">Start</a>(<span class="keywordtype">void</span>)
<a name="l00298"></a>00298         {
<a name="l00299"></a>00299         }
<a name="l00300"></a>00300 
<a name="l00301"></a>00301         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#adae56178a52fd8c78d7e833208087691" title="Stop counting time.">Stop</a>(<span class="keywordtype">void</span>)
<a name="l00302"></a>00302         {
<a name="l00303"></a>00303         }
<a name="l00304"></a>00304 
<a name="l00305"></a>00305         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a641450af19cefdaab88ae2e6c716ca78" title="Clear counted time and events.">Clear</a>(<span class="keywordtype">void</span>)
<a name="l00306"></a>00306         {
<a name="l00307"></a>00307         }
<a name="l00308"></a>00308 
<a name="l00309"></a>00309         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a33c953ccc35f5de9d1e5de5737a3b6b2" title="Start counting time.">start</a>(<span class="keywordtype">void</span>)
<a name="l00310"></a>00310         {
<a name="l00311"></a>00311         }
<a name="l00312"></a>00312 
<a name="l00313"></a>00313         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a9bf75e95615aa61dfa2b07cb33de41f6" title="Stop counting time.">stop</a>(<span class="keywordtype">void</span>)
<a name="l00314"></a>00314         {
<a name="l00315"></a>00315         }
<a name="l00316"></a>00316 
<a name="l00317"></a>00317         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a392d62f749d11465c641df65363a476d" title="Clear counted time and events.">clear</a>(<span class="keywordtype">void</span>)
<a name="l00318"></a>00318         {
<a name="l00319"></a>00319         }
<a name="l00320"></a>00320 
<a name="l00321"></a>00321         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a39fca9814de79fb9c2ce06ea819b24b6" title="Count a specific event for a number of times.">Event</a>(<span class="keyword">const</span> std::string&amp;, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> = 1)
<a name="l00322"></a>00322         {
<a name="l00323"></a>00323         }
<a name="l00324"></a>00324 
<a name="l00325"></a>00325         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a5d76f125e73929ee850a0bac41e5cd95" title="Count a specific event for a number of times.">event</a>(<span class="keyword">const</span> std::string &amp;, <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> = 1)
<a name="l00326"></a>00326         {
<a name="l00327"></a>00327         }
<a name="l00328"></a>00328 
<a name="l00329"></a>00329         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a7bc2411a6a4dc7aa289e421e2f688812" title="Begin counting time for a specific chunk of code.">Begin</a>(<span class="keyword">const</span> std::string &amp;)
<a name="l00330"></a>00330         {
<a name="l00331"></a>00331         }
<a name="l00332"></a>00332 
<a name="l00333"></a>00333         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a276b67abbea043be27684fd1be96bca1" title="Stop counting time for a specific chunk of code.">End</a>(<span class="keyword">const</span> std::string &amp;)
<a name="l00334"></a>00334         {
<a name="l00335"></a>00335         }
<a name="l00336"></a>00336 
<a name="l00337"></a>00337         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a5f1e59ea058ea5ba30fb3e52b3d892d7" title="Begin counting time for a specific chunk of code.">begin</a>(<span class="keyword">const</span> std::string &amp;)
<a name="l00338"></a>00338         {
<a name="l00339"></a>00339         }
<a name="l00340"></a>00340 
<a name="l00341"></a>00341         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#add3c74cb47a2f76c0f517d702301a17d" title="Stop counting time for a specific chunk of code.">end</a>(<span class="keyword">const</span> std::string &amp;)
<a name="l00342"></a>00342         {
<a name="l00343"></a>00343         }
<a name="l00344"></a>00344 
<a name="l00345"></a>00345         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#aeabfce91f1acc251c86c1a99518323a5" title="Print the status of the profiled code chunks and events. Optionally, computation done by different th...">Status</a>(std::ostream &amp; = std::cout, <span class="keywordtype">bool</span> = <span class="keyword">true</span>)
<a name="l00346"></a>00346         {
<a name="l00347"></a>00347         }
<a name="l00348"></a>00348 
<a name="l00349"></a>00349         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a286f3f6f33e494a8babf262bf58162bb" title="Print the status of the profiled code chunks and events. Optionally, computation done by different th...">status</a>(std::ostream &amp; = std::cout, <span class="keywordtype">bool</span> = <span class="keyword">true</span>)
<a name="l00350"></a>00350         {
<a name="l00351"></a>00351         }
<a name="l00352"></a>00352 
<a name="l00353"></a>00353         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a89f18caea7a4952776304db50a135102" title="Print the status of the profiled code chunks and events to the console (using msg::Console)">Console</a>(<span class="keywordtype">void</span>)
<a name="l00354"></a>00354         {
<a name="l00355"></a>00355         }
<a name="l00356"></a>00356 
<a name="l00357"></a>00357         <span class="keywordtype">void</span> <a class="code" href="classompl_1_1Profiler.html#a0945496c0f8e90149ca58e0c6e217ca9" title="Print the status of the profiled code chunks and events to the console (using msg::Console)">console</a>(<span class="keywordtype">void</span>)
<a name="l00358"></a>00358         {
<a name="l00359"></a>00359         }
<a name="l00360"></a>00360 
<a name="l00361"></a>00361     };
<a name="l00362"></a>00362 }
<a name="l00363"></a>00363 
<a name="l00364"></a>00364 <span class="preprocessor">#endif</span>
<a name="l00365"></a>00365 <span class="preprocessor"></span>
<a name="l00366"></a>00366 
<a name="l00367"></a>00367 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div>

<div class="footer span-22 push-2 last">
  <a href="http://www.kavrakilab.org">Physical and Biological Computing Group</a> &bull;
  <a href="http://www.cs.rice.edu">Department of Computer Science</a> &bull;
  <a href="http://www.rice.edu">Rice University</a><br>
  <div class="gray">Generated on Sun Oct 9 2011 23:04:40 by&#160;<a href="http://www.doxygen.org/index.html">doxygen</a> 1.7.4</div>
</div>
</div>
</body>
</html>