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 "system/macros.h"
25#include "system/mem_alloc.h"
26#include "common/profiling.h"
27
28dt_timer_t *dt_timer_start_with_name(const char *file, const char *function, const char *description)
29{
30 dt_timer_t *t = g_malloc(sizeof(dt_timer_t));
31 t->file = file;
32 t->function = function;
33 t->timer = g_timer_new();
34 t->description = description;
35 return t;
36}
37
38void dt_timer_stop_with_name(dt_timer_t *t)
39{
40 g_assert(!IS_NULL_PTR(t));
41 g_timer_stop(t->timer);
42 gulong ms = 0;
43 fprintf(stderr, "Timer %s in function %s took %.3f seconds to execute.\n", t->description, t->function,
44 g_timer_elapsed(t->timer, &ms));
45 g_timer_destroy(t->timer);
46 dt_free(t);
47}
48// clang-format off
49// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
50// vim: shiftwidth=2 expandtab tabstop=2 cindent
51// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
52// clang-format on
53
const char ** description(struct dt_iop_module_t *self)
Definition ashift.c:168
const int t
#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 macros.h:96
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
Definition mem_alloc.h:171
dt_timer_t * dt_timer_start_with_name(const char *file, const char *function, const char *description)
Definition profiling.c:28
void dt_timer_stop_with_name(dt_timer_t *t)
Definition profiling.c:38