Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > SSR > SSR__KMeans__Bench
comparison 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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:7fd1f9bdf757 |
|---|---|
| 1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 2 /* File: wtime.c */ | |
| 3 /* Description: a timer that reports the current wall time */ | |
| 4 /* */ | |
| 5 /* Author: Wei-keng Liao */ | |
| 6 /* ECE Department Northwestern University */ | |
| 7 /* email: wkliao@ece.northwestern.edu */ | |
| 8 /* Copyright, 2005, Wei-keng Liao */ | |
| 9 /* */ | |
| 10 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 11 | |
| 12 #include <sys/time.h> | |
| 13 #include <stdio.h> | |
| 14 #include <stdlib.h> | |
| 15 | |
| 16 /* | |
| 17 * Function: wtime | |
| 18 * --------------- | |
| 19 * Provides a millisecond-resolution timer for measurement purposes. | |
| 20 */ | |
| 21 double wtime(void) | |
| 22 { | |
| 23 double now_time; | |
| 24 struct timeval etstart; | |
| 25 struct timezone tzp; | |
| 26 | |
| 27 if (gettimeofday(&etstart, &tzp) == -1) { | |
| 28 fprintf(stderr, "Timing Error: Could Not Get Current Time\n"); | |
| 29 exit(EXIT_FAILURE); | |
| 30 } | |
| 31 | |
| 32 now_time = ((double)etstart.tv_sec) + /* in seconds */ | |
| 33 ((double)etstart.tv_usec) / 1000000.0; /* in microseconds */ | |
| 34 return now_time; | |
| 35 } | |
| 36 | |
| 37 |
