MBSim |
Project Page |
00001 /* Copyright (C) 2004-2009 MBSim Development Team 00002 * This library is free software; you can redistribute it and/or 00003 * modify it under the terms of the GNU Lesser General Public 00004 * License as published by the Free Software Foundation; either 00005 * version 2.1 of the License, or (at your option) any later version. 00006 * 00007 * This library is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00010 * Lesser General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU Lesser General Public 00013 * License along with this library; if not, write to the Free Software 00014 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 * 00016 * Contact: 00017 * rhuber@users.berlios.de 00018 */ 00019 #ifndef _STOPWATCH_H_ 00020 #define _STOPWATCH_H_ 00021 00029 #ifdef HAVE_SYS_TIME_H 00030 struct timeval; 00031 #endif 00032 00033 namespace MBSim { 00034 00035 class StopWatch { 00036 00037 protected: 00038 00039 #ifdef HAVE_SYS_TIME_H 00040 timeval *begin_tv; 00041 timeval *end_tv; 00042 #else 00043 double begin_d; 00044 double end_d; 00045 #endif 00046 00047 public: 00048 StopWatch(); 00049 ~StopWatch(); 00050 00051 /* \brief starts timer */ 00052 void start(); 00053 /* \brief stops timer and returns enclosed time 00054 * \param reset if flag = true clock is reseted 00055 */ 00056 double stop(bool reset=true); 00057 00058 }; 00059 } 00060 #endif 00061
1.8.0