00001
00008 #ifdef HAVE_CONFIG_H
00009 #include <tumble-conf.h>
00010 #endif
00011
00012 #include "timehelp.h"
00013 #include <cstdlib>
00014
00015 using namespace std;
00016
00017
00018 double elapsed_time_ms(const timeval& start){
00019 timeval now;
00020 gettimeofday(&now,NULL);
00021 return time_diff_ms(start, now);
00022 }
00023
00024 double elapsed_time_sec(const timeval& start){
00025 timeval now;
00026 gettimeofday(&now,NULL);
00027 return time_diff_sec(start, now);
00028 }
00029
00030 double time_diff_ms(const timeval& start, const timeval& end){
00031 return (end.tv_sec - start .tv_sec)*1.0E3 + (end.tv_usec - start.tv_usec)*1.0E-3;
00032 }
00033
00034 double time_diff_sec(const timeval& start, const timeval& end){
00035 return (end.tv_sec - start .tv_sec) + (end.tv_usec - start.tv_usec)*1.0E-6;
00036 }