/// addPeakMemoryMeasurement - This method should be called whenever memory /// usage needs to be checked. It adds a peak memory measurement to the /// currently active timers, which will be printed when the timer group prints /// void Timer::addPeakMemoryMeasurement() { sys::SmartScopedLock<true> L(*TimerLock); size_t MemUsed = getMemUsage(); for (std::vector<Timer*>::iterator I = ActiveTimers->begin(), E = ActiveTimers->end(); I != E; ++I) (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); }
/// addPeakMemoryMeasurement - This method should be called whenever memory /// usage needs to be checked. It adds a peak memory measurement to the /// currently active timers, which will be printed when the timer group prints /// void Timer::addPeakMemoryMeasurement() { size_t MemUsed = getMemUsage(); for (std::vector<Timer*>::iterator I = ActiveTimers->begin(), E = ActiveTimers->end(); I != E; ++I) { (*I)->Lock.acquire(); (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); (*I)->Lock.release(); } }
void Timer::stopTimer() { Time += TimeRecord::getCurrentTime(false); if (ActiveTimers->back() == this) { ActiveTimers->pop_back(); } else { std::vector<Timer*>::iterator I = std::find(ActiveTimers->begin(), ActiveTimers->end(), this); assert(I != ActiveTimers->end() && "stop but no startTimer?"); ActiveTimers->erase(I); } }
void Timer::stopTimer() { sys::SmartScopedLock<true> L(*TimerLock); TimeRecord TR = getTimeRecord(false); Elapsed += TR.Elapsed; UserTime += TR.UserTime; SystemTime += TR.SystemTime; MemUsed += TR.MemUsed; if (ActiveTimers->back() == this) { ActiveTimers->pop_back(); } else { std::vector<Timer*>::iterator I = std::find(ActiveTimers->begin(), ActiveTimers->end(), this); assert(I != ActiveTimers->end() && "stop but no startTimer?"); ActiveTimers->erase(I); } }