Go to the documentation of this file.00001 #ifndef wali_util_TIME_GUARD
00002 #define wali_util_TIME_GUARD
00003
00004 #include <iosfwd>
00005 #include <string>
00006 #include <iostream>
00007 #include <cstdlib>
00008 #include <cstdio>
00009 #include "wali/Common.hpp"
00010 #include "wali/Printable.hpp"
00011 #ifndef _WIN32
00012 # include <sys/times.h>
00013 #else
00014 # include <time.h>
00015 #endif
00016
00017
00018
00019
00020
00021
00022
00023 namespace wali {
00024
00025 namespace util {
00026
00027 class Timer : public wali::Printable {
00028 public:
00029 static bool measureAndReport;
00030 static const long TIMER_CLK_TICK;
00031
00032 Timer(const std::string &task, std::ostream& os=*waliErr);
00033
00034 ~Timer();
00035
00036 double elapsed() const;
00037
00038 virtual std::ostream& print( std::ostream& out ) const;
00039
00040 static std::ostream& printTime( std::ostream& out, clock_t clk );
00041
00042 private:
00043 const clock_t start;
00044 #ifndef _WIN32
00045 struct tms st_tms;
00046 #endif
00047 const std::string task;
00048 std::ostream& os;
00049
00050 };
00051
00052 }
00053
00054 }
00055
00056
00057 #endif // wali_util_TIME_GUARD
00058