comparison lib-src/profile.c @ 9887:be7b66e2cb98

(TV1, TV2): Use EMACS_TIME as type. (get_time): Use EMACS_SUB_TIME.
author Richard M. Stallman <rms@gnu.org>
date Thu, 10 Nov 1994 22:26:57 +0000
parents dd3b83e4ceb0
children 20769d80bc88
comparison
equal deleted inserted replaced
9886:f54af6fe889e 9887:be7b66e2cb98
31 */ 31 */
32 #include <stdio.h> 32 #include <stdio.h>
33 #include <../src/config.h> 33 #include <../src/config.h>
34 #include <../src/systime.h> 34 #include <../src/systime.h>
35 35
36 static struct timeval TV1, TV2; 36 static EMACS_TIME TV1, TV2;
37 static int watch_not_started = 1; /* flag */ 37 static int watch_not_started = 1; /* flag */
38 static char time_string[30]; 38 static char time_string[30];
39 39
40 /* Reset the stopwatch to zero. */ 40 /* Reset the stopwatch to zero. */
41 41
54 get_time () 54 get_time ()
55 { 55 {
56 if (watch_not_started) 56 if (watch_not_started)
57 exit (1); /* call reset_watch first ! */ 57 exit (1); /* call reset_watch first ! */
58 EMACS_GET_TIME (TV2); 58 EMACS_GET_TIME (TV2);
59 if (TV1.tv_usec > TV2.tv_usec) 59 EMACS_SUB_TIME (TV2, TV2, TV1);
60 { 60 sprintf (time_string, "%lu.%06lu", EMACS_SECS(TV2), EMACS_USECS(TV2));
61 TV2.tv_usec += 1000000;
62 TV2.tv_sec--;
63 }
64 sprintf (time_string, "%lu.%06lu",
65 TV2.tv_sec - TV1.tv_sec, TV2.tv_usec - TV1.tv_usec);
66 return time_string; 61 return time_string;
67 } 62 }
68 63
69 void 64 void
70 main () 65 main ()