Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
profiling.c
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010 Henrik Andersson.
4 Copyright (C) 2010-2011 johannes hanika.
5 Copyright (C) 2012 Richard Wonka.
6 Copyright (C) 2014, 2016 Tobias Ellinghaus.
7 Copyright (C) 2020 Pascal Obry.
8 Copyright (C) 2022 Martin Baƙinka.
9
10 darktable is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 darktable is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with darktable. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#include "common/darktable.h"
25#include "common/profiling.h"
26
27dt_timer_t *dt_timer_start_with_name(const char *file, const char *function, const char *description)
28{
29 dt_timer_t *t = g_malloc(sizeof(dt_timer_t));
30 t->file = file;
31 t->function = function;
32 t->timer = g_timer_new();
33 t->description = description;
34 return t;
35}
36
37void dt_timer_stop_with_name(dt_timer_t *t)
38{
39 g_assert(!IS_NULL_PTR(t));
40 g_timer_stop(t->timer);
41 gulong ms = 0;
42 fprintf(stderr, "Timer %s in function %s took %.3f seconds to execute.\n", t->description, t->function,
43 g_timer_elapsed(t->timer, &ms));
44 g_timer_destroy(t->timer);
45 dt_free(t);
46}
47// clang-format off
48// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
49// vim: shiftwidth=2 expandtab tabstop=2 cindent
50// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
51// clang-format on
52
const char ** description(struct dt_iop_module_t *self)
Definition ashift.c:160
#define dt_free(ptr)
Definition darktable.h:456
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition darktable.h:281
const int t
dt_timer_t * dt_timer_start_with_name(const char *file, const char *function, const char *description)
Definition profiling.c:27
void dt_timer_stop_with_name(dt_timer_t *t)
Definition profiling.c:37