NFFT  3.3.2
time.c
00001 /*
00002  * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts
00003  *
00004  * This program is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU General Public License as published by the Free Software
00006  * Foundation; either version 2 of the License, or (at your option) any later
00007  * version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00012  * details.
00013  *
00014  * You should have received a copy of the GNU General Public License along with
00015  * this program; if not, write to the Free Software Foundation, Inc., 51
00016  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "infft.h"
00020 
00021 #ifdef HAVE_TIME_H
00022 #include <time.h>
00023 #endif
00024 
00025 R Y(elapsed_seconds)(ticks t1, ticks t0)
00026 {
00027   UNUSED(t1);
00028   UNUSED(t0);
00029   return (R)(elapsed(t1,t0)) / (R)(TICKS_PER_SECOND);
00030 }
00031 
00032 R Y(clock_gettime_seconds)(void)
00033 {
00034 #if defined(HAVE_CLOCK_GETTIME)
00035   struct timespec tp;
00036   if (clock_gettime(CLOCK_REALTIME, &tp) != 0)
00037   {
00038     tp.tv_sec = 0;
00039     tp.tv_nsec = 0;
00040   }
00041 
00042   return tp.tv_sec+(R)tp.tv_nsec/K(1e9);
00043 #else
00044   return K(0.0);
00045 #endif
00046 }
00047