src/timer.h

00001 /***************************************************************************
00002                           timer.h  -  description
00003                              -------------------
00004     begin                : lun sep 22 2003
00005     copyright            : (C) 2003 by Lynn Hazan
00006     email                : lynn.hazan@myrealbox.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <sys/time.h>
00019 
00020 static struct timeval tv0;
00021 
00022 inline void RestartTimer()
00023 {
00024   struct timezone tz;
00025   gettimeofday(&tv0,&tz);
00026 }
00027 
00028 inline float Timer()
00029 {
00030   struct timeval tv;
00031   struct timezone tz;
00032   gettimeofday(&tv,&tz);
00033   float msec = static_cast<int>(tv.tv_usec/1000)/1000.0;
00034   float msec0 = static_cast<int>(tv0.tv_usec/1000)/1000.0;
00035   float time = (tv.tv_sec+msec)-(tv0.tv_sec+msec0);
00036   return time;
00037 }

Generated on Mon Sep 17 20:47:31 2007 for NeuroScope by  doxygen 1.5.1