From 00b7011a623e31d5cc5b4ae3dd720b029aa4da73 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 20 Jan 2004 00:10:16 +0000 Subject: [PATCH] initial checkin (gettimeofday example) --- time-example.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 time-example.c diff --git a/time-example.c b/time-example.c new file mode 100644 index 0000000..3fada4a --- /dev/null +++ b/time-example.c @@ -0,0 +1,37 @@ +/* + * example of gettimeofday usage + * + */ + +#include +#include +#include // only needed for time command (random seed) +#include + +int main(int argc,char **argv) { + + struct timeval foo1; + struct timeval foo2; + int sec,usec; + int i; + + srand(time(NULL)); // random seed + + printf("time 1:\n"); + gettimeofday(&foo1,NULL); + printf("seconds: %d \t usec: %d\n",(int)foo1.tv_sec,(int)foo1.tv_usec); + + while(i