spnktime.cpp
来自「linux 下的程序源代码」· C++ 代码 · 共 43 行
CPP
43 行
/* * Copyright 2008 Stephen Liu * For license terms, see the file COPYING along with this library. */#include <sys/time.h>#include <stdio.h>#include "spnktime.hpp"SP_NKClock :: SP_NKClock(){ gettimeofday ( &mBornTime, NULL ); gettimeofday ( &mPrevTime, NULL ); }SP_NKClock :: ~SP_NKClock(){}long SP_NKClock :: getAge(){ struct timeval now; gettimeofday ( &now, NULL ); return (long)( ( 1000000.0 * ( now.tv_sec - mBornTime.tv_sec ) + ( now.tv_usec - mBornTime.tv_usec ) ) / 1000.0 );}long SP_NKClock :: getInterval(){ struct timeval now; gettimeofday ( &now, NULL ); long ret = long( ( 1000000.0 * ( now.tv_sec - mPrevTime.tv_sec ) + ( now.tv_usec - mPrevTime.tv_usec ) ) / 1000.0 ); mPrevTime = now; return ret;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?