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/timer.hpp

Go to the documentation of this file.
00001 //
00002 // Simple class for timing code (low resolution).
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_TIMER_HPP_INCLUDED
00016 #define OCTANE_TIMER_HPP_INCLUDED
00017 
00018 #include <ctime>
00019 
00020 // use namespace for clock and clock_t which should be in std::
00021 // namespace but visual c++ 6 compatibility means we cant
00022 // explicitly refer to std::clock_t.
00023 using namespace std;
00024 
00032 class OctaneTimer {
00033 
00034 public:
00036     OctaneTimer() : begin(clock()), elapsed(0.0) { ; }
00037 
00039     void start() { begin = clock(); }
00040 
00044     float stop()
00045     {
00046         clock_t end = clock();
00047         elapsed = (float)(end - begin)/(float)CLOCKS_PER_SEC;
00048         return elapsed;
00049     }
00050 
00054     float get_elapsed() const { return elapsed; }
00055 
00056 private:
00057     clock_t begin;
00058     float elapsed;
00059 };
00060 
00061 #endif // OCTANE_TIMER_HPP_INCLUDED
 
Generated on 20 May 2004 by doxygen 1.3.3