libposix: implement gettimeofday

This commit is contained in:
2017-08-25 00:53:10 +02:00
parent 2409419ba2
commit bd149a18f1
7 changed files with 108 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
#include <stdio.h>
#include <sys/time.h>
int main (int argc, char** argv) {
struct timeval tvalBefore, tvalAfter;
long delta;
gettimeofday (&tvalBefore, NULL);
int i =0;
while (i < 10000)
i++;
gettimeofday (&tvalAfter, NULL);
// Changed format to long int (%ld), changed time calculation
delta = ((tvalAfter.tv_sec - tvalBefore.tv_sec)*1000000L
+tvalAfter.tv_usec) - tvalBefore.tv_usec;
printf("Time in microseconds: %ld microseconds\n", delta);
if(delta > 0)
return 0;
return 1;
}