00001 /* 00002 * See the dyninst/COPYRIGHT file for copyright information. 00003 * 00004 * We provide the Paradyn Tools (below described as "Paradyn") 00005 * on an AS IS basis, and do not warrant its validity or performance. 00006 * We reserve the right to update, modify, or discontinue this 00007 * software at any time. We shall have no obligation to supply such 00008 * updates or modifications or any other form of support to you. 00009 * 00010 * By your use of Paradyn, you understand and agree that we (or any 00011 * other person or entity with proprietary rights in Paradyn) are 00012 * under no obligation to provide either maintenance services, 00013 * update services, notices of latent defects, or correction of 00014 * defects for Paradyn. 00015 * 00016 * This library is free software; you can redistribute it and/or 00017 * modify it under the terms of the GNU Lesser General Public 00018 * License as published by the Free Software Foundation; either 00019 * version 2.1 of the License, or (at your option) any later version. 00020 * 00021 * This library is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00024 * Lesser General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU Lesser General Public 00027 * License along with this library; if not, write to the Free Software 00028 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00029 */ 00030 00031 /************************************************************************ 00032 * Timer.h: timer functions (for posix systems). 00033 ************************************************************************/ 00034 00035 00036 #if !defined(_Timer_h_) 00037 #define _Timer_h_ 00038 00039 00040 /************************************************************************ 00041 * header files. 00042 ************************************************************************/ 00043 #include "common/h/headers.h" 00044 #include "common/h/std_namesp.h" 00045 00046 00047 /************************************************************************ 00048 * class timer 00049 ************************************************************************/ 00050 00051 class COMMON_EXPORT timer { 00052 public: 00053 timer (); 00054 timer (const timer &); 00055 ~timer (); 00056 00057 timer& operator= (const timer &); 00058 timer& operator+= (const timer &); 00059 timer operator+ (const timer &) const; 00060 00061 void clear (); 00062 void start (); 00063 void stop (); 00064 00065 double usecs () const; 00066 double ssecs () const; 00067 double wsecs () const; 00068 00069 bool is_running () const; 00070 00071 double CYCLES_PER_SEC() const { return CYCLES_PER_SEC_;} 00072 double NANOSECS_PER_SEC() const { return NANOSECS_PER_SEC_;} 00073 double MICROSECS_PER_SEC() const { return MICROSECS_PER_SEC_;} 00074 00075 // friend 00076 // ostream& operator<< (ostream &os, const timer &t) { 00077 // t.print(os); return os;} 00078 00079 private: 00080 // void print (ostream &); 00081 00082 static 00083 void get_current (double &, double &, double &); 00084 00085 double usecs_, ssecs_, wsecs_; 00086 double cu_, cs_, cw_; 00087 unsigned activation_count_; 00088 00089 const double CYCLES_PER_SEC_; 00090 const double MICROSECS_PER_SEC_; 00091 const double NANOSECS_PER_SEC_; 00092 }; 00093 00094 #endif /* !defined(_Timer_h_) */
1.6.1