Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
times.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef DT_COMMON_TIMES_H
19#define DT_COMMON_TIMES_H
20
21/* Wall-clock / CPU-time measurement helpers. The dt_show_times* implementations
22 * live in darktable.c (they honor the runtime perf-debug flag), but the
23 * declarations are application-free: low-level code includes this instead of
24 * darktable.h. */
25
26#ifdef _WIN32
27#include "win/getrusage.h"
28#else
29#include <sys/resource.h>
30#endif
31#include <sys/time.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37typedef struct
38{
39 double clock;
40 double user;
42
43static inline double dt_get_wtime(void)
44{
45 struct timeval time;
46 gettimeofday(&time, NULL);
47 return time.tv_sec - 1290608000 + (1.0 / 1000000.0) * time.tv_usec;
48}
49
50static inline void dt_get_times(dt_times_t *t)
51{
52 struct rusage ru;
53
55 t->clock = dt_get_wtime();
56 t->user = ru.ru_utime.tv_sec + ru.ru_utime.tv_usec * (1.0 / 1000000.0);
57}
58
59/* Wall-clock time (dt_get_wtime() domain) at which the application started.
60 * Written once at startup, never mutated; implemented in darktable.c. */
61double dt_get_start_wtime(void);
62
63void dt_show_times(const dt_times_t *start, const char *prefix);
64
65void dt_show_times_f(const dt_times_t *start, const char *prefix, const char *suffix, ...) __attribute__((format(printf, 3, 4)));
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif // DT_COMMON_TIMES_H
72
73// clang-format off
74// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
75// vim: shiftwidth=2 expandtab tabstop=2 cindent
76// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
77// clang-format on
const int t
int getrusage(int who, struct rusage *usage)
Definition getrusage.c:54
#define RUSAGE_SELF
Definition getrusage.h:54
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
Definition simd.h:55
double clock
Definition times.h:39
double user
Definition times.h:40
void dt_show_times(const dt_times_t *start, const char *prefix)
Definition darktable.c:2128
double dt_get_start_wtime(void)
Definition darktable.c:2070
static void dt_get_times(dt_times_t *t)
Definition times.h:50
static double dt_get_wtime(void)
Definition times.h:43
void dt_show_times_f(const dt_times_t *start, const char *prefix, const char *suffix,...) __attribute__((format(printf