~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to libs/rubberband/src/Profiler.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
 
2
 
 
3
/*
 
4
    Rubber Band
 
5
    An audio time-stretching and pitch-shifting library.
 
6
    Copyright 2007-2008 Chris Cannam.
 
7
    
 
8
    This program is free software; you can redistribute it and/or
 
9
    modify it under the terms of the GNU General Public License as
 
10
    published by the Free Software Foundation; either version 2 of the
 
11
    License, or (at your option) any later version.  See the file
 
12
    COPYING included with this distribution for more information.
 
13
*/
 
14
 
 
15
#ifndef _PROFILER_H_
 
16
#define _PROFILER_H_
 
17
 
 
18
#define NO_TIMING 1
 
19
 
 
20
//#define WANT_TIMING 1
 
21
//#define PROFILE_CLOCKS 1
 
22
 
 
23
#ifdef NDEBUG
 
24
#ifndef WANT_TIMING
 
25
#define NO_TIMING 1
 
26
#endif
 
27
#endif
 
28
 
 
29
#ifndef NO_TIMING
 
30
#ifdef PROFILE_CLOCKS
 
31
#include <time.h>
 
32
#else
 
33
#include "sysutils.h"
 
34
#ifndef _WIN32
 
35
#include <sys/time.h>
 
36
#endif
 
37
#endif
 
38
#endif
 
39
 
 
40
#include <map>
 
41
 
 
42
namespace RubberBand {
 
43
 
 
44
#ifndef NO_TIMING
 
45
 
 
46
class Profiler
 
47
{
 
48
public:
 
49
    Profiler(const char *name);
 
50
    ~Profiler();
 
51
 
 
52
    void end(); // same action as dtor
 
53
 
 
54
    static void dump();
 
55
 
 
56
protected:
 
57
    const char* m_c;
 
58
#ifdef PROFILE_CLOCKS
 
59
    clock_t m_start;
 
60
#else
 
61
    struct timeval m_start;
 
62
#endif
 
63
    bool m_showOnDestruct;
 
64
    bool m_ended;
 
65
 
 
66
    typedef std::pair<int, float> TimePair;
 
67
    typedef std::map<const char *, TimePair> ProfileMap;
 
68
    typedef std::map<const char *, float> WorstCallMap;
 
69
    static ProfileMap m_profiles;
 
70
    static WorstCallMap m_worstCalls;
 
71
    static void add(const char *, float);
 
72
};
 
73
 
 
74
#else
 
75
 
 
76
class Profiler
 
77
{
 
78
public:
 
79
    Profiler(const char *) { }
 
80
    ~Profiler() { }
 
81
 
 
82
    void update() const { }
 
83
    void end() { }
 
84
    static void dump() { }
 
85
};
 
86
 
 
87
#endif
 
88
 
 
89
}
 
90
 
 
91
#endif