scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

0071-clock.c (342B)


      1 /*
      2 output:
      3 testing
      4 difftime=1
      5 done
      6 end:
      7 */
      8 #include <stdio.h>
      9 #include <time.h>
     10 
     11 int
     12 main(void)
     13 {
     14 	time_t t1, t2;
     15 	clock_t k1, k2;
     16 
     17 	t1 = time(NULL);
     18 	puts("testing");
     19 
     20 	for (k1 = k2 = clock(); (k2 - k1) / CLOCKS_PER_SEC < 1; k2 = clock())
     21 		;
     22 	t2 = time(NULL);
     23 	printf("difftime=%d\n",  difftime(t2, t1) >= 1);
     24 
     25 	puts("done");
     26 
     27 	return 0;
     28 }