BRL-CAD
time.h
Go to the documentation of this file.
1/* T I M E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2023 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_TIME_H
22#define BU_TIME_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_time
35 * @brief
36 * Cross platform wrapper for microsecond accuracy timing functionality.
37 */
38/** @{ */
39/** @file bu/time.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 */
54BU_EXPORT extern int64_t bu_gettime(void);
55
56/**
57 * Evaluate the time_t input as UTC time in ISO format.
58 *
59 * The UTC time is written into the user-provided bu_vls struct and is
60 * also returned and guaranteed to be a non-null result, returning a
61 * static "NULL" UTC time if an error is encountered.
62 */
63BU_EXPORT void bu_utctime(struct bu_vls *utc_result, const int64_t time_val);
64
65/** @} */
66
67__END_DECLS
68
69#endif /* BU_TIME_H */
70
71/*
72 * Local Variables:
73 * mode: C
74 * tab-width: 8
75 * indent-tabs-mode: t
76 * c-file-style: "stroustrup"
77 * End:
78 * ex: shiftwidth=4 tabstop=8
79 */
Header file for the BRL-CAD common definitions.
void bu_utctime(struct bu_vls *utc_result, const int64_t time_val)
int64_t bu_gettime(void)
Definition: vls.h:53