Commit source
This commit is contained in:
21
TVALCPU/src/timestamp.cpp
Normal file
21
TVALCPU/src/timestamp.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* utility.cpp
|
||||
*
|
||||
* Created on: Mar 22, 2011
|
||||
* Author: ditlevsen
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <cstdlib>
|
||||
|
||||
// get time stamp in seconds using Native Linux Time Measurement
|
||||
double get_timestamp() {
|
||||
struct timeval tp;
|
||||
double sec, usec;
|
||||
gettimeofday(&tp, NULL);
|
||||
sec = static_cast<double>( tp.tv_sec );
|
||||
usec = static_cast<double>( tp.tv_usec )/1E6;
|
||||
return sec + usec;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user