📄 timespan.h
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) Yeico S. A. de C. V. * xlsLib -- A multiplatform, C++ library for dynamic generation of Excel (TM) * files. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Source: /cvsroot/xlslib/xlslib/src/common/timespan.h,v $ * $Revision: 1.1.1.1 $ * $Author: darioglz $ * $Date: 2004/08/27 16:32:05 $ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * File description: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */#ifndef TIMESPAN_H#define TIMESPAN_H#include "config.h"#include "systype.h"#include <time.h>#include <assert.h>class CCpuClockTimespan{ enum { INVALID_VALUE = -1, }; public: CCpuClockTimespan() : m_clockStart( INVALID_VALUE), m_nUsedClockTicks( INVALID_VALUE) {} ~CCpuClockTimespan() {} void StartClock() { // the clock is already started !!! // stop it first !!! assert( m_clockStart == INVALID_VALUE); m_nUsedClockTicks = INVALID_VALUE; m_clockStart = clock(); } void StopClock() { const clock_t clockStop = clock(); // start the clock first !!! assert( m_clockStart != INVALID_VALUE); m_nUsedClockTicks = clockStop - m_clockStart; // after this, we can start it again !!! m_clockStart = INVALID_VALUE; } unsigned long GetUsedMilliseconds() const { const int MILLISECONDS_PER_SECOND = 1000; // the clock was never started, // or it's started, but it has not been stopped yet assert( m_nUsedClockTicks != INVALID_VALUE); double nSeconds = ( ( double)m_nUsedClockTicks) / CLOCKS_PER_SEC; const unsigned long nMilliseconds =(clock_t) ( unsigned long)( nSeconds * MILLISECONDS_PER_SECOND); return nMilliseconds; } private: // when did we Start to measure // clock time? int m_clockStart; // the used clock ticks, from Start to Stop int m_nUsedClockTicks;};#endif //TIMESPAN_H/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * $Log: timespan.h,v $ * Revision 1.1.1.1 2004/08/27 16:32:05 darioglz * Initial Import. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -