/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ /* $Id: osaStopwatch.cpp,v 1.2 2007/04/26 19:33:57 anton Exp $ Author(s): Ofri Sadowsky Created on: 2005-02-17 (C) Copyright 2005-2007 Johns Hopkins University (JHU), All Rights Reserved. --- begin cisst license - do not edit --- This software is provided "as is" under an open source license, with no warranty. The complete license can be found in license.txt and http://www.cisst.org/cisst/license.txt. --- end cisst license --- */ #include bool osaStopwatch::HasHighPerformanceCounter = false; double osaStopwatch::GetTimeGranularity() const { #if (CISST_OS == CISST_WINDOWS) || (CISST_OS == CISST_CYGWIN) static bool gotPerformanceFreq = false; static LARGE_INTEGER frequency = { 0, 0 }; if (!gotPerformanceFreq) { HasHighPerformanceCounter = (::QueryPerformanceFrequency( &frequency )) ? true : false; gotPerformanceFreq = true; } if (HasHighPerformanceCounter) return 1.0 / double( frequency.QuadPart ); else return 0.001; #elif (CISST_COMPILER == CISST_GCC) return 1.0e-6; #endif } // **************************************************************************** // Change History // **************************************************************************** // // $Log: osaStopwatch.cpp,v $ // Revision 1.2 2007/04/26 19:33:57 anton // All files in libraries: Applied new license text, separate copyright and // updated dates, added standard header where missing. // // Revision 1.1 2007/02/16 18:57:55 ofri // cisstOSAbstraction library: Added class osaStopwatch based on recent discussion // // Revision 1.2 2006/08/31 18:38:00 ofri // mscStopwatch : Rewritten to use Windows "high performance counter" directly. // // Revision 1.1 2005/02/24 16:22:33 ofri // Added classes mscDtopwatch and mscOutputFormatter // // // ****************************************************************************