This:
Code:
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
struct tms tmsBegin,tmsEnd;
void time_start() { times(&tmsBegin); }
long time_stop()
{ times(&tmsEnd);
return ((tmsEnd.tms_utime-tmsBegin.tms_utime)+
(tmsEnd.tms_stime-tmsBegin.tms_stime))*1000/CLK_TCK;
}
int main()
{
time_start();
for(int t=0; t<1000000; t++)
printf("Test 1: %d\n", t);
printf("Result: %ld\n", time_stop());
}
I took this code from the Internet, here's the log after trying to copy:
Code:
test.c: In function ‘time_start’:
test.c:6:1: warning: implicit declaration of function ‘times’ [-Wimplicit-function-declaration]
void time_start() { times(&tmsBegin); }
^
test.c: In function ‘time_stop’:
test.c:9:3: error: invalid use of undefined type ‘struct tms’
return ((tmsEnd.tms_utime-tmsBegin.tms_utime)+
^
test.c:9:3: error: invalid use of undefined type ‘struct tms’
test.c:10:11: error: invalid use of undefined type ‘struct tms’
(tmsEnd.tms_stime-tmsBegin.tms_stime))*1000/CLK_TCK;
^
test.c:10:11: error: invalid use of undefined type ‘struct tms’