Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > SSR > SSR__KMeans__Bench
annotate wtime.c @ 0:0ce47c784647
Initial commit
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 27 Sep 2011 15:08:02 +0200 |
| parents | |
| children |
| rev | line source |
|---|---|
| msach@0 | 1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| msach@0 | 2 /* File: wtime.c */ |
| msach@0 | 3 /* Description: a timer that reports the current wall time */ |
| msach@0 | 4 /* */ |
| msach@0 | 5 /* Author: Wei-keng Liao */ |
| msach@0 | 6 /* ECE Department Northwestern University */ |
| msach@0 | 7 /* email: wkliao@ece.northwestern.edu */ |
| msach@0 | 8 /* Copyright, 2005, Wei-keng Liao */ |
| msach@0 | 9 /* */ |
| msach@0 | 10 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| msach@0 | 11 |
| msach@0 | 12 #include <sys/time.h> |
| msach@0 | 13 #include <stdio.h> |
| msach@0 | 14 #include <stdlib.h> |
| msach@0 | 15 |
| msach@0 | 16 /* |
| msach@0 | 17 * Function: wtime |
| msach@0 | 18 * --------------- |
| msach@0 | 19 * Provides a millisecond-resolution timer for measurement purposes. |
| msach@0 | 20 */ |
| msach@0 | 21 double wtime(void) |
| msach@0 | 22 { |
| msach@0 | 23 double now_time; |
| msach@0 | 24 struct timeval etstart; |
| msach@0 | 25 struct timezone tzp; |
| msach@0 | 26 |
| msach@0 | 27 if (gettimeofday(&etstart, &tzp) == -1) { |
| msach@0 | 28 fprintf(stderr, "Timing Error: Could Not Get Current Time\n"); |
| msach@0 | 29 exit(EXIT_FAILURE); |
| msach@0 | 30 } |
| msach@0 | 31 |
| msach@0 | 32 now_time = ((double)etstart.tv_sec) + /* in seconds */ |
| msach@0 | 33 ((double)etstart.tv_usec) / 1000000.0; /* in microseconds */ |
| msach@0 | 34 return now_time; |
| msach@0 | 35 } |
| msach@0 | 36 |
| msach@0 | 37 |
