]> mj.ucw.cz Git - libucw.git/blob - ucw/time.h
0684bec16bf187a7e3b65b2f61488955fdc0806c
[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 /***
14  * === Timestamps
15  *
16  * All timing functions in LibUCW are based on signed 64-bit timestamps
17  * with millisecond precision (the <<basics:type_timestamp_t,`timestamp_t`>> type), which measure
18  * time from an unspecified moment in the past. Depending on the compile-time
19  * settings, that moment can be the traditional UNIX epoch, or for example
20  * system boot if POSIX monotonic clock is used.
21  ***/
22
23 /* time-stamp.c */
24
25 timestamp_t get_timestamp(void);                /** Get current time as a millisecond timestamp. **/
26
27 /***
28  * === Timers
29  *
30  * A timer is a very simple construct for measuring execution time.
31  * It can be initialized and then read multiple times. Each read returns
32  * the number of milliseconds elapsed since the previous read or initialization.
33  ***/
34
35 /* time-timer.c */
36
37 void init_timer(timestamp_t *timer);            /** Initialize a timer. **/
38 uns get_timer(timestamp_t *timer);              /** Get the number of milliseconds since last init/get of a timer. **/
39 uns switch_timer(timestamp_t *oldt, timestamp_t *newt); /** Stop ticking of one timer and resume another. **/
40
41 #endif