source: libcaca/trunk/caca/caca_prof.h @ 4328

Last change on this file since 4328 was 4095, checked in by Sam Hocevar, 10 years ago

Increase profiling timers' sliding mean accuracy.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1/*
2 *  libcaca       Colour ASCII-Art library
3 *  Copyright (c) 2009 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  $Id: caca_prof.h 4095 2009-12-07 01:05:31Z sam $
7 *
8 *  This library is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14/*
15 *  This file contains profiling functions.
16 */
17
18#ifndef __CACA_PROF_H__
19#define __CACA_PROF_H__
20
21#if defined PROF && !defined __KERNEL__
22#   define PROFILING_VARS
23
24#   define STAT_IADD(_s, _n) \
25      do \
26      { \
27        struct caca_stat *s = _s; \
28        int i, n = _n; \
29        for (i = STAT_VALUES - 1; i > 0; i--) \
30            s->itable[i] = s->itable[i - 1]; \
31        s->itable[0] = n; \
32        s->imean = (s->imean * 63 + (int64_t)n * 64 + 32) / 64; \
33      } \
34      while(0)
35
36#   define START_PROF(obj, fn)
37#   define STOP_PROF(obj, fn)
38
39#else
40#   define PROFILING_VARS
41#   define STAT_IADD(_s, _n) do { } while(0)
42#   define START_PROF(obj, fn) do { } while(0)
43#   define STOP_PROF(obj, fn) do { } while(0)
44#endif
45
46#endif /* __CACA_PROF_H__ */
47
Note: See TracBrowser for help on using the repository browser.