Freeciv-3.1: /fast/freeciv/nightly/S3_1/utility/timing.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
timing.h
Go to the documentation of this file.
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)
6 any later version.
7
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***********************************************************************/
13
14/* Measuring times; original author: David Pfitzner <dwp@mso.anu.edu.au> */
15
16#ifndef FC__TIMING_H
17#define FC__TIMING_H
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
23#include "support.h" /* bool type */
24
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.
29*/
30#define LOG_TIMERS
31
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)
36#define DEBUG_TIMERS
37#endif
38
39 enum timer_timetype {
40 TIMER_CPU, /* time spent by the CPU */
41 TIMER_USER /* time as seen by the user ("wall clock") */
42};
43
44 enum timer_use {
45 TIMER_ACTIVE, /* use this timer */
46 TIMER_IGNORE /* ignore this timer */
47};
48/*
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.
54 */
55
56#ifdef FREECIV_DEBUG
57#define TIMER_DEBUG TIMER_ACTIVE
58#else
59#define TIMER_DEBUG TIMER_IGNORE
60#endif
61
62struct timer; /* opaque type; see comments in timing.c */
63
64#define SPECLIST_TAG timer
65#define SPECLIST_TYPE struct timer
66#include "speclist.h"
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
70
71
72struct timer *timer_new(enum timer_timetype type, enum timer_use use);
73struct timer *timer_renew(struct timer *t, enum timer_timetype type,
74 enum timer_use use);
75
76void timer_destroy(struct timer *t);
77bool timer_in_use(struct timer *t);
78
79void timer_clear(struct timer *t);
80void timer_start(struct timer *t);
81void timer_stop(struct timer *t);
82
83double timer_read_seconds(struct timer *t);
84
85void timer_usleep_since_start(struct timer *t, long usec);
86
87#ifdef __cplusplus
88}
89#endif /* __cplusplus */
90
91#endif /* FC__TIMER_H */
type
GType type
Definition repodlgs.c:1312
speclist.h
timer
Definition timing.c:81
timer::t
time_t t
Definition timing.c:100
timer::usec
long usec
Definition timing.c:89
timer::use
enum timer_use use
Definition timing.c:84
support.h
timer_new
struct timer * timer_new(enum timer_timetype type, enum timer_use use)
Definition timing.c:157
timer_usleep_since_start
void timer_usleep_since_start(struct timer *t, long usec)
Definition timing.c:364
timer_clear
void timer_clear(struct timer *t)
Definition timing.c:212
timer_in_use
bool timer_in_use(struct timer *t)
Definition timing.c:202
timer_destroy
void timer_destroy(struct timer *t)
Definition timing.c:191
timer_start
void timer_start(struct timer *t)
Definition timing.c:224
timer_stop
void timer_stop(struct timer *t)
Definition timing.c:268
timer_use
timer_use
Definition timing.h:44
TIMER_ACTIVE
@ TIMER_ACTIVE
Definition timing.h:45
TIMER_IGNORE
@ TIMER_IGNORE
Definition timing.h:46
timer_read_seconds
double timer_read_seconds(struct timer *t)
Definition timing.c:344
timer_renew
struct timer * timer_renew(struct timer *t, enum timer_timetype type, enum timer_use use)
Definition timing.c:176
timer_timetype
timer_timetype
Definition timing.h:39
TIMER_CPU
@ TIMER_CPU
Definition timing.h:40
TIMER_USER
@ TIMER_USER
Definition timing.h:41