UTimer.h
Go to the documentation of this file.
00001 /*
00002 *  utilite is a cross-platform library with
00003 *  useful utilities for fast and small developing.
00004 *  Copyright (C) 2010  Mathieu Labbe
00005 *
00006 *  utilite is free library: you can redistribute it and/or modify
00007 *  it under the terms of the GNU Lesser General Public License as published by
00008 *  the Free Software Foundation, either version 3 of the License, or
00009 *  (at your option) any later version.
00010 *
00011 *  utilite is distributed in the hope that it will be useful,
00012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 *  GNU Lesser General Public License for more details.
00015 *
00016 *  You should have received a copy of the GNU Lesser General Public License
00017 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 #ifndef UTIMER_H
00021 #define UTIMER_H
00022 
00023 #include "rtabmap/utilite/UtiLiteExp.h" // DLL export/import defines
00024 
00025 #ifdef _WIN32
00026 #include <windows.h>
00027 #else
00028 #include <sys/time.h>
00029 #include <time.h>
00030 #endif
00031 
00046 class UTILITE_EXP UTimer
00047 {
00048 public:
00049     UTimer();
00050     ~UTimer();
00051 
00057     static double now();
00058 
00062     void start();
00063 
00067     void stop();
00068 
00075     double elapsed() {return getElapsedTime();}
00076     double getElapsedTime();
00077 
00084     UTILITE_DEPRECATED(double getInterval());
00085 
00094     double restart() {return ticks();}
00095     double ticks();
00096 
00097 private:
00098 #ifdef _WIN32
00099     LARGE_INTEGER startTimeRecorded_; /* When we start the timer, timeRecorded is copied over lastTimeRecorded.*/
00100     LARGE_INTEGER stopTimeRecorded_;  /* When we stop the timer. */
00101 
00102     LARGE_INTEGER frequency_;          /* Keep the frequency of the counter */
00103 #else
00104     struct timeval startTimeRecorded_; /* When we start the timer, timeRecorded is copied over lastTimeRecorded.*/
00105     struct timeval stopTimeRecorded_;  /* When we stop the timer. */
00106 #endif
00107 };
00108 
00109 #endif //UTIMER_H


rtabmap
Author(s): Mathieu Labbe
autogenerated on Sat Jul 23 2016 11:44:28