add 0.5 second sleep after closing JACK connection so that next startup/connect is...
[ardour.git] / libs / rubberband / src / Profiler.h
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