nanosecond resolution in progress

This commit is contained in:
Gwenhael Le Moine 2024-04-18 16:59:29 +02:00
parent c0c9d637a4
commit de90eaffdd
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -1,6 +1,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h> #include <sys/time.h>
#include "config.h" #include "config.h"
@ -8,10 +10,16 @@
#include "gui.h" #include "gui.h"
#include "display.h" #include "display.h"
static long long time_in_useconds( void )
{
struct timespec ts;
timespec_get( &ts, TIME_UTC );
return ( long long )ts.tv_sec * 1000000000 + ts.tv_nsec;
}
long long time_in_mseconds( void ) long long time_in_mseconds( void )
{ {
struct timeval tv; struct timeval tv;
gettimeofday( &tv, NULL ); gettimeofday( &tv, NULL );
return ( ( ( long long )tv.tv_sec ) * 1000 ) + ( tv.tv_usec / 1000 ); return ( ( ( long long )tv.tv_sec ) * 1000 ) + ( tv.tv_usec / 1000 );
} }
@ -20,7 +28,7 @@ long long currentTime;
// gui_update // gui_update
long long lastTime_gui_update = 0; long long lastTime_gui_update = 0;
long long delay_gui_update = 16; long long delay_gui_update = 16; // 15625;
int main( int argc, char* argv[] ) int main( int argc, char* argv[] )
{ {