comparison base/Profiler.cpp @ 408:115f60df1e4d

* Speed up spectrogram painting by releasing mutex in FFTDataServer while calculating data prior to writing it, and by adding whole-column value query methods to FFT objects * Add paint cache to Thumbwheel -- repaints of this widget were slowing down the whole spectrogram repaint * More uses of MutexLocker (named and with debug) and more profile points * Make startup much quicker some of the time, with OSC server in place
author Chris Cannam
date Thu, 08 May 2008 14:46:22 +0000
parents dc46851837d6
children 29efe322ab47
comparison
equal deleted inserted replaced
407:88ad01799040 408:115f60df1e4d
159 159
160 fprintf(stderr, "\nBy worst case:\n"); 160 fprintf(stderr, "\nBy worst case:\n");
161 for (TimeRMap::const_iterator i = worstmap.end(); i != worstmap.begin(); ) { 161 for (TimeRMap::const_iterator i = worstmap.end(); i != worstmap.begin(); ) {
162 --i; 162 --i;
163 fprintf(stderr, "%-40s %s ms\n", i->second, 163 fprintf(stderr, "%-40s %s ms\n", i->second,
164 (i->first * 1000).toString().c_str(), i->second); 164 (i->first * 1000).toString().c_str());
165 } 165 }
166 166
167 fprintf(stderr, "\nBy number of calls:\n"); 167 fprintf(stderr, "\nBy number of calls:\n");
168 for (IntRMap::const_iterator i = ncallmap.end(); i != ncallmap.begin(); ) { 168 for (IntRMap::const_iterator i = ncallmap.end(); i != ncallmap.begin(); ) {
169 --i; 169 --i;
173 #endif 173 #endif
174 } 174 }
175 175
176 #ifndef NO_TIMING 176 #ifndef NO_TIMING
177 177
178 Profiler::Profiler(const char* c, bool showOnDestruct) 178 Profiler::Profiler(const char* c, bool showOnDestruct) :
179 : m_c(c), 179 m_c(c),
180 m_showOnDestruct(showOnDestruct) 180 m_showOnDestruct(showOnDestruct),
181 m_ended(false)
181 { 182 {
182 m_startCPU = clock(); 183 m_startCPU = clock();
183 184
184 struct timeval tv; 185 struct timeval tv;
185 (void)gettimeofday(&tv, 0); 186 (void)gettimeofday(&tv, 0);
200 << "ms CPU, " << elapsedTime << " real" << endl; 201 << "ms CPU, " << elapsedTime << " real" << endl;
201 } 202 }
202 203
203 Profiler::~Profiler() 204 Profiler::~Profiler()
204 { 205 {
206 if (!m_ended) end();
207 }
208
209 void
210 Profiler::end()
211 {
205 clock_t elapsedCPU = clock() - m_startCPU; 212 clock_t elapsedCPU = clock() - m_startCPU;
206 213
207 struct timeval tv; 214 struct timeval tv;
208 (void)gettimeofday(&tv, 0); 215 (void)gettimeofday(&tv, 0);
209 RealTime elapsedTime = RealTime::fromTimeval(tv) - m_startTime; 216 RealTime elapsedTime = RealTime::fromTimeval(tv) - m_startTime;
212 219
213 if (m_showOnDestruct) 220 if (m_showOnDestruct)
214 cerr << "Profiler : id = " << m_c 221 cerr << "Profiler : id = " << m_c
215 << " - elapsed = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC) 222 << " - elapsed = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC)
216 << "ms CPU, " << elapsedTime << " real" << endl; 223 << "ms CPU, " << elapsedTime << " real" << endl;
224
225 m_ended = true;
217 } 226 }
218 227
219 #endif 228 #endif
220 229