Skip to content

Instantly share code, notes, and snippets.

@chmike
Created December 12, 2012 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chmike/4266372 to your computer and use it in GitHub Desktop.
Save chmike/4266372 to your computer and use it in GitHub Desktop.
Get the current time as a double float in second units. Handy to compute processing time interval.
#include <sys/time.h>
// Return the current time as a double float in second units
double getTimeAsDouble()
{
struct timeval t;
::gettimeofday( &t, NULL );
return double(t.tv_sec) + double(t.tv_usec)/1000000.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment