projects/aaron/marco_generator.cpp
// function to calculate time deltas using the real time clock
// tf = ending time (timespec structure)
// ts = starting time (timespec structure)
// return value is floating point in seconds
function to calculate time deltas using the real time clock
tf = ending time (timespec structure)
ts = starting time (timespec structure)
return value is floating point in seconds
function to calculate time deltas using the real time clock tf = ending time ( timespec structure ) ts = starting time ( timespec structure ) return value is floating point in seconds
double delta_time(timespec ts, timespec tf) {
	long int diff_sec, diff_ns;		
	diff_sec = tf.tv_sec - ts.tv_sec;
	diff_ns = tf.tv_nsec - ts.tv_nsec;
	if (diff_ns < 0) {
		diff_ns = diff_ns + 1000000000;
		diff_sec--;
	}
	return (double)(diff_sec + diff_ns/1e9);
}
double delta_time ( timespec ts , timespec tf ) { long int diff_sec , diff_ns ; diff_sec = tf . tv_sec - ts . tv_sec ; diff_ns = tf . tv_nsec - ts . tv_nsec ; if ( diff_ns < 0 ) { diff_ns = diff_ns + 1000000000 ; diff_sec -- ; } return ( double ) ( diff_sec + diff_ns / 1e9 ) ; }
function to calculate time deltas using the real time clock
tf = ending time (timespec structure)
ts = starting time (timespec structure)
return value is floating point in seconds
function to calculate time deltas using the real time clock tf = ending time ( timespec structure ) ts = starting time ( timespec structure ) return value is floating point in seconds
// time differences in seconds and nanoseconds //std::cout << "tf = " << tf.tv_sec << " . " << tf.tv_nsec << "\n"; //std::cout << "ts = " << ts.tv_sec << " . " << ts.tv_nsec << "\n"; //std::cout << "diff = " << diff_sec << " . " << diff_ns << "\n";