Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

utilityclasses/timer/scope_timer.hpp

Go to the documentation of this file.
00001 //
00002 // Simple timer, measuring time from construction to destruction.
00003 //
00004 // Copyright (c) 2003 by Octane Project Group
00005 // All Rights Reserved
00006 //
00007 // http://octane.sourceforge.net/
00008 //
00009 
00014 
00015 #ifndef OCTANE_SCOPE_TIMER_HPP_INCLUDED
00016 #define OCTANE_SCOPE_TIMER_HPP_INCLUDED
00017 
00018 #include <iostream>
00019 #include <string>
00020 
00021 #include "timer.hpp"
00022 
00027 class OctaneScopeTimer {
00028 
00029 public:
00034     OctaneScopeTimer(const std::string _pre="<scope_timer> ",
00035                  const std::string _post=" seconds\n",
00036                  std::ostream &_to=std::cout)
00037        : pre(_pre), post(_post), to(_to)
00038     { ; }
00039 
00042     float get_elapsed() { return t.stop(); }
00043 
00046     ~OctaneScopeTimer() { to << pre << t.stop() << post; }
00047 
00048 private:
00049     const std::string pre, post;
00050     std::ostream &to;
00051     OctaneTimer t;
00052 };
00053 
00054 #endif // OCTANE_SCOPE_TIMER_HPP_INCLUDED
 
Generated on 20 May 2004 by doxygen 1.3.3