/******************************************************************************* * ALMA - Atacama Large Millimiter Array * Copyright (c) European Southern Observatory, 2011 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * "@(#) $Id: acstimeProfiler.cpp,v 1.13 2011/10/28 15:12:04 hsommer Exp $" */ //------------------------------------------------------------------------------ #include "acstimeProfiler.h" #include #include "acsutilTimeStamp.h" //------------------------------------------------------------------------------ Profiler::Profiler() { reset(); } //------------------------------------------------------------------------------ void Profiler::reset() { lastStart_m=0; totalTime=0; totalNumStarts_m=0; //pick a ridiculously large value! minDuration=0xFFFFFFFFULL; maxDuration=0; extraDescrip_m = ""; } //------------------------------------------------------------------------------ void Profiler::start() { //double-check this to make sure they don't call start twice without a stop! if (lastStart_m==0) { totalNumStarts_m++; } else { std::cerr << "Looks like Profiler::start was called twice in a row without invoking Profiler::stop" << std::endl; } //get the current time. lastStart_m=getTimeStamp(); } //------------------------------------------------------------------------------ ACS::Time Profiler::stop() { //save the current time if (lastStart_m==0) { std::cerr << "Looks like Profiler::stop was called twice in a row without invoking Profiler::start" << std::endl; return 0ULL; } ACS::Time timeDiff = getTimeStamp() - lastStart_m; if (timeDiff>maxDuration) { maxDuration=timeDiff; } if (timeDiff