~ubuntu-branches/ubuntu/raring/libcaca/raring

« back to all changes in this revision

Viewing changes to caca/caca_prof.h

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar
  • Date: 2010-02-08 01:40:59 UTC
  • mfrom: (1.1.8 upstream) (4.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100208014059-9q4av8pze8p7uw3i
Tags: 0.99.beta17-1
New upstream release.

Show diffs side-by-side

added added

removed removed

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