Mercurial > emacs
comparison lib-src/profile.c @ 8336:52590f967c1e
(reset_watch, get_time): Use EMACS_GET_TIME.
(tzp): Var deleted.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 25 Jul 1994 23:21:24 +0000 |
parents | 92cef0f29878 |
children | dd3b83e4ceb0 |
comparison
equal
deleted
inserted
replaced
8335:e6afa5879de3 | 8336:52590f967c1e |
---|---|
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 struct timeval TV1, TV2; |
37 static struct timezone *tzp = (struct timezone *) NULL; /* no need timezone */ | |
38 static int watch_not_started = 1; /* flag */ | 37 static int watch_not_started = 1; /* flag */ |
39 static char time_string[30]; | 38 static char time_string[30]; |
40 | |
41 #ifndef HAVE_GETTIMEOFDAY | |
42 gettimeofday () | |
43 { | |
44 fprintf (stderr, "profile: this system does not support gettimeofday\n"); | |
45 exit (1); | |
46 } | |
47 #endif | |
48 | 39 |
49 /* Reset the stopwatch to zero. */ | 40 /* Reset the stopwatch to zero. */ |
50 | 41 |
51 int | 42 int |
52 reset_watch () | 43 reset_watch () |
53 { | 44 { |
54 gettimeofday (&TV1, tzp); | 45 EMACS_GET_TIME (TV1); |
55 watch_not_started = 0; | 46 watch_not_started = 0; |
56 } | 47 } |
57 | 48 |
58 /* This call returns the time since the last reset_watch call. The time | 49 /* This call returns the time since the last reset_watch call. The time |
59 is returned as a string with the format <seconds>.<micro-seconds> | 50 is returned as a string with the format <seconds>.<micro-seconds> |
62 char * | 53 char * |
63 get_time () | 54 get_time () |
64 { | 55 { |
65 if (watch_not_started) | 56 if (watch_not_started) |
66 exit (1); /* call reset_watch first ! */ | 57 exit (1); /* call reset_watch first ! */ |
67 gettimeofday (&TV2, tzp); | 58 EMACS_GET_TIME (TV2); |
68 if (TV1.tv_usec > TV2.tv_usec) | 59 if (TV1.tv_usec > TV2.tv_usec) |
69 { | 60 { |
70 TV2.tv_usec += 1000000; | 61 TV2.tv_usec += 1000000; |
71 TV2.tv_sec--; | 62 TV2.tv_sec--; |
72 } | 63 } |