]> mj.ucw.cz Git - libucw.git/blob - ucw/time.h
tableprinter: update of documentation
[libucw.git] / ucw / time.h
1 /*
2  *      UCW Library -- A Simple Millisecond Timer
3  *
4  *      (c) 2007--2012 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _UCW_TIMER_H
11 #define _UCW_TIMER_H
12
13 #ifdef CONFIG_UCW_CLEAN_ABI
14 #define get_timer ucw_get_timer
15 #define get_timestamp ucw_get_timestamp
16 #define init_timer ucw_init_timer
17 #define switch_timer ucw_switch_timer
18 #define timestamp_type ucw_timestamp_type
19 #endif
20
21 /***
22  * === Timestamps
23  *
24  * All timing functions in LibUCW are based on signed 64-bit timestamps
25  * with millisecond precision (the <<basics:type_timestamp_t,`timestamp_t`>> type), which measure
26  * time from an unspecified moment in the past. Depending on the compile-time
27  * settings, that moment can be the traditional UNIX epoch, or for example
28  * system boot if POSIX monotonic clock is used.
29  ***/
30
31 /* time-stamp.c */
32
33 timestamp_t get_timestamp(void);                /** Get current time as a millisecond timestamp. **/
34
35 /* time-conf.c */
36
37 /**
38  * A user type for parsing of time intervals in configuration files.
39  * It is specified as fractional seconds and internally converted to
40  * a <<basics:type_timestamp_t,`timestamp_t`>>. When conversion of
41  * a non-zero value yields zero, an error is raised.
42  **/
43 extern struct cf_user_type timestamp_type;
44
45 /***
46  * === Timers
47  *
48  * A timer is a very simple construct for measuring execution time.
49  * It can be initialized and then read multiple times. Each read returns
50  * the number of milliseconds elapsed since the previous read or initialization.
51  ***/
52
53 /* time-timer.c */
54
55 void init_timer(timestamp_t *timer);            /** Initialize a timer. **/
56 uint get_timer(timestamp_t *timer);             /** Get the number of milliseconds since last init/get of a timer. **/
57 uint switch_timer(timestamp_t *oldt, timestamp_t *newt);        /** Stop ticking of one timer and resume another. **/
58
59 #endif