Merge branch 'master' into develop
[jack2.git] / common / JackEngineProfiling.h
blob894566a145ff3aab28c13239788bd089da66b0b9
1 /*
2 Copyright (C) 2008 Grame & RTL
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __JackEngineProfiling__
21 #define __JackEngineProfiling__
23 #include "types.h"
24 #include "JackTypes.h"
25 #include "JackConstants.h"
26 #include "JackShmMem.h"
28 namespace Jack
31 #define TIME_POINTS 100000
32 #define FAILURE_TIME_POINTS 10000
33 #define FAILURE_WINDOW 10
34 #define MEASURED_CLIENTS 32
36 /*!
37 \brief Timing structure for a client.
40 PRE_PACKED_STRUCTURE
41 struct JackTimingMeasureClient
43 int fRefNum;
44 jack_time_t fSignaledAt;
45 jack_time_t fAwakeAt;
46 jack_time_t fFinishedAt;
47 jack_client_state_t fStatus;
49 JackTimingMeasureClient()
50 :fRefNum(-1),
51 fSignaledAt(0),
52 fAwakeAt(0),
53 fFinishedAt(0),
54 fStatus((jack_client_state_t)0)
57 } POST_PACKED_STRUCTURE;
59 /*!
60 \brief Timing interval in the global table for a given client
63 PRE_PACKED_STRUCTURE
64 struct JackTimingClientInterval
66 int fRefNum;
67 char fName[JACK_CLIENT_NAME_SIZE + 1];
68 int fBeginInterval;
69 int fEndInterval;
71 JackTimingClientInterval()
72 :fRefNum(-1),
73 fBeginInterval(-1),
74 fEndInterval(-1)
77 } POST_PACKED_STRUCTURE;
79 /*!
80 \brief Timing structure for a table of clients.
83 PRE_PACKED_STRUCTURE
84 struct JackTimingMeasure
86 unsigned int fAudioCycle;
87 jack_time_t fPeriodUsecs;
88 jack_time_t fCurCycleBegin;
89 jack_time_t fPrevCycleEnd;
90 JackTimingMeasureClient fClientTable[CLIENT_NUM];
92 JackTimingMeasure()
93 :fAudioCycle(0),
94 fPeriodUsecs(0),
95 fCurCycleBegin(0),
96 fPrevCycleEnd(0)
99 } POST_PACKED_STRUCTURE;
102 \brief Client timing monitoring.
105 class JackClientInterface;
106 class JackGraphManager;
108 PRE_PACKED_STRUCTURE
109 class SERVER_EXPORT JackEngineProfiling
112 private:
114 JackTimingMeasure fProfileTable[TIME_POINTS];
115 JackTimingClientInterval fIntervalTable[MEASURED_CLIENTS];
117 unsigned int fAudioCycle;
118 unsigned int fMeasuredClient;
120 bool CheckClient(const char* name, int cur_point);
122 public:
124 JackEngineProfiling();
125 ~JackEngineProfiling();
127 void Profile(JackClientInterface** table,
128 JackGraphManager* manager,
129 jack_time_t period_usecs,
130 jack_time_t cur_cycle_begin,
131 jack_time_t prev_cycle_end);
133 JackTimingMeasure* GetCurMeasure();
135 } POST_PACKED_STRUCTURE;
137 } // end of namespace
139 #endif