aboutsummaryrefslogtreecommitdiff
path: root/doc/Manual/en/BH_Timer.pod
blob: 56e79fecad9e7b40dccb8e47813dd01340e252a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
=encoding UTF-8


=head1 NAME

BH_Timer - timer utilities


=head1 SYNTAX

 #include <BH/Timer.h>

 cc prog.c -o prog -lbh


=head1 DESCRIPTION

This module provides a simple high-resolution timer interface for measuring
elapsed time. The timer uses a monotonic clock source when available, making it
suitable for accurate time measurements, such as profiling or timeouts. It
supports millisecond and nanosecond precision and can be started, restarted,
and queried for elapsed time.



=head1 API CALLS


=head2 BH_TimerNew

 BH_Timer *BH_TimerNew(void);

Creates and initializes a new timer object.

Returns a pointer to a newly allocated BH_Timer on success, or NULL on failure.


=head2 BH_TimerFree

 void BH_TimerFree(BH_Timer *timer);

Destroys the timer.

=head2 BH_TimerIsMonotonic

 int BH_TimerIsMonotonic(BH_Timer *timer);

Checks whether the timer uses a monotonic clock source.


=head2 BH_TimerStart

 void BH_TimerStart(BH_Timer *timer);

Starts or resets the timer to begin counting from the current time.


=head2 BH_TimerRestart

 int64_t BH_TimerRestart(BH_Timer *timer);

Restarts the timer and returns the number of milliseconds that had elapsed since
the start of the timer.


=head2 BH_TimerMilliseconds

 int64_t BH_TimerMilliseconds(BH_Timer *timer);

Returns the number of milliseconds that had elapsed since the start of the
timer.


=head2 BH_TimerNanoseconds

 int64_t BH_TimerNanoseconds(BH_Timer *timer);

Returns the number of nanoseconds that had elapsed since the start of the timer.

=head1 SEE ALSO

L<BH>