BRL-CAD
Loading...
Searching...
No Matches
datetime.h
Go to the documentation of this file.
1
/* D A T E T I M E . H
2
* BRL-CAD
3
*
4
* Copyright (c) 2004-2026 United States Government as represented by
5
* the U.S. Army Research Laboratory.
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public License
9
* version 2.1 as published by the Free Software Foundation.
10
*
11
* This library is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this file; see the file named COPYING for more
18
* information.
19
*/
20
21
#ifndef BU_DATETIME_H
22
#define BU_DATETIME_H
23
24
#include "
common.h
"
25
26
#include <stddef.h>
/* for size_t */
27
#include <stdlib.h>
/* for getenv */
28
29
#include "
bu/defines.h
"
30
#include "
bu/vls.h
"
31
32
__BEGIN_DECLS
33
34
/** @addtogroup bu_datetime
35
* @brief
36
* Cross platform wrapper for timing functionality.
37
*/
38
/** @{ */
39
/** @file bu/datetime.h */
40
41
/**
42
* Returns a microsecond-accurate wall-clock time counter.
43
*
44
* Example use:
45
* @code
46
* int64_t start = bu_gettime();
47
* do_some_work_here();
48
* double elapsed = bu_gettime() - start;
49
* double seconds = elapsed / 1000000.0;
50
* printf("time: %.2f\n", seconds);
51
* @endcode
52
*
53
*/
54
BU_EXPORT
extern
int64_t
bu_gettime
(
void
);
55
56
/**
57
* Returns a high-resolution CPU (user+system) time counter for the
58
* current process, in nanoseconds.
59
*
60
* Unlike bu_gettime(), this value is not a wall-clock or epoch timestamp. It
61
* measures CPU time consumed by the process across all threads. Returns -1 if
62
* a process CPU timer is not available on the platform.
63
*/
64
BU_EXPORT
extern
int64_t
bu_timer_cpu
(
void
);
65
66
/**
67
* Returns a high-resolution CPU (user+system) time counter for the
68
* current thread, in nanoseconds.
69
*
70
* This is useful for profiling small regions of threaded work without charging
71
* scheduler preemption or other threads' work to the measured interval.
72
* Returns -1 if a current-thread CPU timer is not available on the platform.
73
*/
74
BU_EXPORT
extern
int64_t
bu_timer_cpu_thread
(
void
);
75
76
/**
77
* Evaluate the time_t input as UTC time in ISO format.
78
*
79
* The UTC time is written into the user-provided bu_vls struct and is
80
* also returned and guaranteed to be a non-null result, returning a
81
* static "NULL" UTC time if an error is encountered.
82
*/
83
BU_EXPORT
void
bu_utctime
(
struct
bu_vls
*
utc_result
,
const
int64_t
time_val
);
84
85
/** @} */
86
87
__END_DECLS
88
89
#endif
/* BU_DATETIME_H */
90
91
/*
92
* Local Variables:
93
* mode: C
94
* tab-width: 8
95
* indent-tabs-mode: t
96
* c-file-style: "stroustrup"
97
* End:
98
* ex: shiftwidth=4 tabstop=8
99
*/
defines.h
dvec
Definition
dvec.h:74
common.h
Header file for the BRL-CAD common definitions.
bu_utctime
void bu_utctime(struct bu_vls *utc_result, const int64_t time_val)
bu_timer_cpu_thread
int64_t bu_timer_cpu_thread(void)
bu_gettime
int64_t bu_gettime(void)
bu_timer_cpu
int64_t bu_timer_cpu(void)
bu_vls
Definition
vls.h:53
vls.h
include
bu
datetime.h
Generated on Mon Aug 17 2026 00:59:52 for BRL-CAD by
1.9.8