prof.h

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 1999-2004 California Institute of Technology
00006 // Copyright (c) 2004-2007 University of Southern California
00007 // Rob Peters <rjpeters at klab dot caltech dot edu>
00008 //
00009 // created: Thu Jun 30 14:47:11 2005
00010 // commit: $Id: prof.h 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/rutz/prof.h $
00012 //
00013 // --------------------------------------------------------------------
00014 //
00015 // This file is part of GroovX.
00016 //   [http://www.klab.caltech.edu/rjpeters/groovx/]
00017 //
00018 // GroovX is free software; you can redistribute it and/or modify it
00019 // under the terms of the GNU General Public License as published by
00020 // the Free Software Foundation; either version 2 of the License, or
00021 // (at your option) any later version.
00022 //
00023 // GroovX is distributed in the hope that it will be useful, but
00024 // WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 // General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License
00029 // along with GroovX; if not, write to the Free Software Foundation,
00030 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00031 //
00033 
00034 #ifndef GROOVX_RUTZ_PROF_H_UTC20050630214711_DEFINED
00035 #define GROOVX_RUTZ_PROF_H_UTC20050630214711_DEFINED
00036 
00037 #include "rutz/time.h"
00038 
00039 #include <iosfwd>
00040 
00041 namespace rutz
00042 {
00043   class prof;
00044 }
00045 
00047 
00089 class rutz::prof
00090 {
00091 public:
00092   prof(const char* s, const char* fname, int lineno) throw();
00093   ~prof() throw();
00094 
00096   enum timing_mode
00097     {
00098       WALLCLOCK, 
00099       RUSAGE     
00100     };
00101 
00103   static timing_mode get_timing_mode() throw()
00104   { return s_timing_mode; }
00105 
00107   static void set_timing_mode(timing_mode mode) throw()
00108   { s_timing_mode = mode; }
00109 
00111   static rutz::time get_now_time(timing_mode mode) throw()
00112   {
00113     switch (mode)
00114       {
00115       case rutz::prof::RUSAGE:
00116         return (rutz::time::user_rusage() + rutz::time::sys_rusage());
00117 
00118       case rutz::prof::WALLCLOCK:
00119       default:
00120         return rutz::time::wall_clock_now();
00121       }
00122   }
00123 
00125   void reset() throw();
00126 
00128   unsigned int count() const throw();
00129 
00130   void add_time(const rutz::time& t) throw();
00131 
00132   void add_child_time(const rutz::time& t) throw();
00133 
00134   const char* context_name() const throw();
00135 
00136   const char* src_file_name() const throw();
00137 
00138   int src_line_no() const throw();
00139 
00141   double total_time() const throw();
00142 
00144   double self_time() const throw();
00145 
00147   double avg_self_time() const throw();
00148 
00150   void print_prof_data(FILE* f) const throw();
00151 
00153   void print_prof_data(std::ostream& os) const throw();
00154 
00156   static void print_at_exit(bool yes_or_no) throw();
00157 
00159   static void prof_summary_file_name(const char* fname);
00160 
00162   static void reset_all_prof_data() throw();
00163 
00165   static void print_all_prof_data(FILE* f) throw();
00166 
00168   static void print_all_prof_data(std::ostream& os) throw();
00169 
00170 private:
00171   prof(const prof&) throw();
00172   prof& operator=(const prof&) throw();
00173 
00174   const char*  const m_context_name;
00175   const char*  const m_src_file_name;
00176   int          const m_src_line_no;
00177   unsigned int       m_call_count;
00178   rutz::time         m_total_time;
00179   rutz::time         m_children_time;
00180 
00181   static timing_mode s_timing_mode;
00182 };
00183 
00184 static const char __attribute__((used)) vcid_groovx_rutz_prof_h_utc20050630214711[] = "$Id: prof.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00185 #endif // !GROOVX_RUTZ_PROF_H_UTC20050630214711DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:40 2008 by Doxygen version 1.5.5.