00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00023 #ifndef VCSN_MISC_TIMER_HXX
00024 # define VCSN_MISC_TIMER_HXX
00025 
00026 # include <iosfwd>
00027 
00028 # include <sys/times.h>
00029 # include <unistd.h>
00030 
00031 # ifdef VAUCANSON
00032 #  include <vaucanson/misc/timer.hh>
00033 # else
00034 #  include "timer.hh"
00035 # endif
00036 
00037 NAMESPACE_VCSN_BEGIN
00038 
00039 namespace misc
00040 {
00041 
00042   
00043 
00044 
00045 
00046 
00047   inline
00048   Timer::~Timer ()
00049   {
00050   }
00051 
00052   
00053 
00054 
00055 
00056 
00057   inline
00058   bool
00059   Timer::operator< (const Timer& rhs) const
00060   {
00061     precondition (! (is_running_ || rhs.is_running_));
00062 
00063     return graph_[0].total.cpu < rhs.graph_[0].total.cpu;
00064   }
00065 
00066   
00067 
00068 
00069 
00070 
00071   inline
00072   void
00073   Timer::build_connected_components ()
00074   {
00075     comp_id_.resize (num_vertices (graph_));
00076     comp_count_ = strong_components (graph_, &comp_id_[0]);
00077   }
00078 
00079   
00080 
00081 
00082 
00083 
00084   inline
00085   std::ostream&
00086   Timer::print (std::ostream&         o,
00087                 timer::verbose_degree vd) const
00088   {
00089     print_output_graph(o, vd);
00090 
00091     return o;
00092   }
00093 
00094   inline
00095   std::ostream&
00096   Timer::export_dot (std::ostream&         o,
00097                      timer::verbose_degree vd,
00098                      double                ccr) const
00099   {
00100     write_graphviz (o, graph_,
00101                     timer::VertexWriter (*this, vd, ccr),
00102                     timer::EdgeWriter   (*this, vd, ccr),
00103                     timer::GraphWriter  (*this, vd, ccr));
00104     return o;
00105   }
00106 
00107   
00108 
00109 
00110 
00111   inline
00112   ScopedTimer::ScopedTimer (Timer&             timer,
00113                             const unsigned int i)
00114   {
00115     timer_ = &timer;
00116     timer.push (i);
00117   }
00118 
00119   inline
00120   ScopedTimer::ScopedTimer (Timer&             timer,
00121                             const std::string& name)
00122   {
00123     timer_ = &timer;
00124     timer.push (name);
00125   }
00126 
00127   inline
00128   ScopedTimer::~ScopedTimer ()
00129   {
00130     timer_->pop ();
00131   }
00132 
00133   
00134 
00135 
00136 
00138   inline
00139   std::ostream&
00140   operator<< (std::ostream& o,
00141               const Timer&  t)
00142   {
00143     return t.print (o, timer::VERBOSE_NONE);
00144   }
00145 
00146 
00147 } 
00148 
00149 NAMESPACE_VCSN_END
00150 
00151 #endif