comparison base/Profiler.cpp @ 1527:710e6250a401 zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:14 +0100
parents 48e9f538e6e9
children 70e172e6cc59
comparison
equal deleted inserted replaced
1324:d4a28d1479a8 1527:710e6250a401
98 98
99 fprintf(stderr, "%s(%d):\n", *i, pp.first); 99 fprintf(stderr, "%s(%d):\n", *i, pp.first);
100 100
101 fprintf(stderr, "\tCPU: \t%.9g ms/call \t[%d ms total]\n", 101 fprintf(stderr, "\tCPU: \t%.9g ms/call \t[%d ms total]\n",
102 (((double)pp.second.first * 1000.0 / 102 (((double)pp.second.first * 1000.0 /
103 (double)pp.first) / CLOCKS_PER_SEC), 103 (double)pp.first) / CLOCKS_PER_SEC),
104 int((double(pp.second.first) * 1000.0) / CLOCKS_PER_SEC)); 104 int((double(pp.second.first) * 1000.0) / CLOCKS_PER_SEC));
105 105
106 fprintf(stderr, "\tReal: \t%s ms \t[%s ms total]\n", 106 fprintf(stderr, "\tReal: \t%s ms \t[%s ms total]\n",
107 ((pp.second.second / pp.first) * 1000).toString().c_str(), 107 ((pp.second.second / pp.first) * 1000).toString().c_str(),
108 (pp.second.second * 1000).toString().c_str()); 108 (pp.second.second * 1000).toString().c_str());
190 struct timeval tv; 190 struct timeval tv;
191 (void)gettimeofday(&tv, 0); 191 (void)gettimeofday(&tv, 0);
192 RealTime elapsedTime = RealTime::fromTimeval(tv) - m_startTime; 192 RealTime elapsedTime = RealTime::fromTimeval(tv) - m_startTime;
193 193
194 cerr << "Profiler : id = " << m_c 194 cerr << "Profiler : id = " << m_c
195 << " - elapsed so far = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC) 195 << " - elapsed so far = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC)
196 << "ms CPU, " << elapsedTime << " real" << endl; 196 << "ms CPU, " << elapsedTime << " real" << endl;
197 } 197 }
198 198
199 Profiler::~Profiler() 199 Profiler::~Profiler()
200 { 200 {
201 if (!m_ended) end(); 201 if (!m_ended) end();
213 Profiles::getInstance()->accumulate(m_c, elapsedCPU, elapsedTime); 213 Profiles::getInstance()->accumulate(m_c, elapsedCPU, elapsedTime);
214 214
215 if (m_showOnDestruct) 215 if (m_showOnDestruct)
216 cerr << "Profiler : id = " << m_c 216 cerr << "Profiler : id = " << m_c
217 << " - elapsed = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC) 217 << " - elapsed = " << ((elapsedCPU * 1000) / CLOCKS_PER_SEC)
218 << "ms CPU, " << elapsedTime << " real" << endl; 218 << "ms CPU, " << elapsedTime << " real" << endl;
219 219
220 m_ended = true; 220 m_ended = true;
221 } 221 }
222 222
223 #endif 223 #endif