1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 /* Measuring times; original author: David Pfitzner <dwp@mso.anu.edu.au> */
21 #endif /* __cplusplus */
23 #include "support.h" /* bool type */
25 /* Undefine this if you don't want timing measurements to appear in logs.
26 This is useful if you want to compare logs of two freeciv runs and
27 want to see only differences in control flow, and not diffs full of
28 different timing results.
32 /* Timing logging happens so often only in debug builds that it makes
33 sense to have macro defined for it once here and to have all the
34 checks against that single macro instead of two separate. */
35 #if defined(LOG_TIMERS) && defined(FREECIV_DEBUG)
40 TIMER_CPU
, /* time spent by the CPU */
41 TIMER_USER
/* time as seen by the user ("wall clock") */
45 TIMER_ACTIVE
, /* use this timer */
46 TIMER_IGNORE
/* ignore this timer */
49 * TIMER_IGNORE is to leave a timer in the code, but not actually
50 * use it, and not make any time-related system calls for it.
51 * It is also used internally to turn off timers if the system
52 * calls indicate that timing is not available.
53 * Also note TIMER_DEBUG below.
57 #define TIMER_DEBUG TIMER_ACTIVE
59 #define TIMER_DEBUG TIMER_IGNORE
62 struct timer
; /* opaque type; see comments in timing.c */
64 #define SPECLIST_TAG timer
65 #define SPECLIST_TYPE struct timer
67 #define timer_list_iterate(ARG_list, NAME_item) \
68 TYPED_LIST_ITERATE(struct timer, (ARG_list), NAME_item)
69 #define timer_list_iterate_end LIST_ITERATE_END
72 struct timer
*timer_new(enum timer_timetype type
, enum timer_use use
);
73 struct timer
*timer_renew(struct timer
*t
, enum timer_timetype type
,
76 void timer_destroy(struct timer
*t
);
77 bool timer_in_use(struct timer
*t
);
79 void timer_clear(struct timer
*t
);
80 void timer_start(struct timer
*t
);
81 void timer_stop(struct timer
*t
);
83 double timer_read_seconds(struct timer
*t
);
85 void timer_usleep_since_start(struct timer
*t
, long usec
);
89 #endif /* __cplusplus */
91 #endif /* FC__TIMER_H */