summaryrefslogtreecommitdiff
path: root/gegl/gegl-instrument.h
blob: 7dd6cb5004f44a82eb0e5edeaa2f558a307a72c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* This file is part of GEGL
 *
 * GEGL is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * GEGL is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2006 Øyvind Kolås
 */
#ifndef GEGL_INSTRUMENT_H
#define GEGL_INSTRUMENT_H

extern gboolean gegl_instrument_enabled;

/* return number of usecs since gegl was initialized */
long gegl_ticks               (void);

/* start tracking times with gegl_instrument */
void gegl_instrument_enable   (void);

#define GEGL_INSTRUMENT_START() \
  { long _gegl_instrument_ticks = 0; \
    if (gegl_instrument_enabled) { _gegl_instrument_ticks = gegl_ticks (); }

#define GEGL_INSTRUMENT_END(parent, scale) \
    if (gegl_instrument_enabled) { \
      real_gegl_instrument (parent, scale, gegl_ticks () - _gegl_instrument_ticks); \
                                 } \
  }

/* store a timing instrumentation (parent is expected to exist,
 * and to keep it's own record of the time-slice reported) */
#define gegl_instrument(parent, scale, usecs) \
  { if (gegl_instrument_enabled) { \
real_gegl_instrument (parent, scale, usecs); \
                                 } }

void real_gegl_instrument     (const gchar *parent,
                               const gchar *scale,
                               long         usecs);

/* create a utf8 string with bar charts for where time disappears
 * during a gegl-run
 */
gchar * gegl_instrument_utf8 (void);

#endif