• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetCurrentTime函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetCurrentTime函数的典型用法代码示例。如果您正苦于以下问题:C++ GetCurrentTime函数的具体用法?C++ GetCurrentTime怎么用?C++ GetCurrentTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetCurrentTime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: srand

void Monster::JudegeAttack()
{
	srand((UINT)GetCurrentTime());
	int x = rand()%100;
	if(x>98)
	{
	this->AttackAnimation("monster_attack",5,MonsterDirecton);
	}

}
开发者ID:appleappleapple,项目名称:GameOfFighting,代码行数:10,代码来源:Monster.cpp


示例2: RunEnqueueDequeueTrial

/*
 * Function: RunEnqueueDequeueTrial
 * --------------------------------
 * Runs the enqueue & dequeue time trials for the specified
 * pqueue size.  Reports results to cout.
 * Note that we just randomly choose numbers to insert.
 * The amount of time it takes to do one enqueue/dequeue is
 * too small to be accurately measured, so we do many iterations in 
 * a loop and time that.
 */
void RunEnqueueDequeueTrial(int size)
{
	PQueue pq;
	
	for (int i = 0; i < size; i++)
		pq.enqueue(RandomInteger(1,size));
	
    cout << "Time to enqueue into " << size << "-element pqueue: " << flush;
    double start = GetCurrentTime();
    for (int j = 0; j < NumRepetitions; j++) 
	    pq.enqueue(RandomInteger(1, 2*size));
    cout << 1000*(GetCurrentTime() - start)/NumRepetitions << " usecs" << endl;

    cout << "Time to dequeue from " << size << "-element pqueue: " << flush;
    start = GetCurrentTime();
    for (int k = 0; k < NumRepetitions; k++) 
	    pq.dequeueMax();
    cout << 1000*(GetCurrentTime() - start)/NumRepetitions << " usecs" << endl;
}
开发者ID:azavadil,项目名称:CS106B_PA,代码行数:29,代码来源:performance.cpp


示例3: WinMain

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static int iKeep [NUM][4] ;
     HDC        hdcScr, hdcMem ;
     int        cx, cy ;
     HBITMAP    hBitmap ;
     HWND       hwnd ;
     int        i, j, x1, y1, x2, y2 ;

     if (LockWindowUpdate (hwnd = GetDesktopWindow ()))
     {
          hdcScr  = GetDCEx (hwnd, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE) ;
          hdcMem  = CreateCompatibleDC (hdcScr) ;
          cx      = GetSystemMetrics (SM_CXSCREEN) / 10 ;
          cy      = GetSystemMetrics (SM_CYSCREEN) / 10 ;
          hBitmap = CreateCompatibleBitmap (hdcScr, cx, cy) ;

          SelectObject (hdcMem, hBitmap) ;

          srand ((int) GetCurrentTime ()) ;

          for (i = 0 ; i < 2   ; i++)
          for (j = 0 ; j < NUM ; j++)
          {
               if (i == 0)
               {
                    iKeep [j] [0] = x1 = cx * (rand () % 10) ;
                    iKeep [j] [1] = y1 = cy * (rand () % 10) ;

                    iKeep [j] [2] = x2 = cx * (rand () % 10) ;
                    iKeep [j] [3] = y2 = cy * (rand () % 10) ;
               }
               else
               {
                    x1 = iKeep [NUM - 1 - j] [0] ;
                    y1 = iKeep [NUM - 1 - j] [1] ;
                    x2 = iKeep [NUM - 1 - j] [2] ;
                    y2 = iKeep [NUM - 1 - j] [3] ;
               }
               BitBlt (hdcMem,  0,  0, cx, cy, hdcScr, x1, y1, SRCCOPY) ;
               BitBlt (hdcScr, x1, y1, cx, cy, hdcScr, x2, y2, SRCCOPY) ;
               BitBlt (hdcScr, x2, y2, cx, cy, hdcMem,  0,  0, SRCCOPY) ;

               Sleep (10) ;
          }

          DeleteDC (hdcMem) ;
          ReleaseDC (hwnd, hdcScr) ;
          DeleteObject (hBitmap) ;

          LockWindowUpdate (NULL) ;
     }
     return FALSE ;
}
开发者ID:JohnXinhua,项目名称:UVa,代码行数:55,代码来源:main.cpp


示例4: kernel_main

/*======================================================================*
kernel_main
*======================================================================*/
PUBLIC int kernel_main()
{
	Init8259A();
	Init8253();
	SetIRQ();
	
	k_reenter = -1;
	ticks = 0;
	get_boot_params(&BootParam);
	GetCurrentTime(&systime);			//?áè?RTCê±??

	int i, j, eflags, prio;
        u8  rpl;
        u8  priv; 

	TASK * t;
	PROCESS * p = proc_table;

	char * stk = task_stack + STACK_SIZE_TOTAL + 0x4000;

	for (i = 0; i < NR_TASKS + NR_PROCS; i++,p++,t++) {
		if (i >= NR_TASKS + NR_NATIVE_PROCS) 
		{
			p->p_flags = FREE_SLOT;
			p->ldt_sel = SELECTOR_LDT_FIRST + (i << 3);		//空槽也要给LDT赋值否则调度任务会#GP异常
			continue;
		}

	        if (i < NR_TASKS) {     
                        t	= task_table + i;
                        priv	= PRIVILEGE_TASK;
                        rpl     = RPL_TASK;
                        eflags  = 0x1202;
			prio    = 1;
                }
                else {                  
                        t	= user_proc_table + (i - NR_TASKS);
                        priv	= PRIVILEGE_USER;
                        rpl     = RPL_USER;
                        eflags  = 0x202;	
			prio    = 1;
                }

		strcpy(p->name, t->name);	
		p->p_parent = NO_TASK;

		if (strcmp(t->name, "INIT") != 0) {
			p->ldts[INDEX_LDT_C]  = gdt[SELECTOR_KERNEL_CS >> 3];
			p->ldts[INDEX_LDT_RW] = gdt[SELECTOR_KERNEL_DS >> 3];

			
			p->ldts[INDEX_LDT_C].attr1  = DA_C   | priv << 5;
			p->ldts[INDEX_LDT_RW].attr1 = DA_DRW | priv << 5;
		}
		else {		
开发者ID:OscarLGH,项目名称:Orange-OS,代码行数:58,代码来源:Process.c


示例5: EffectEnd

// https://w3c.github.io/web-animations/#finish-an-animation
void
Animation::Finish(ErrorResult& aRv)
{
  if (mPlaybackRate == 0 ||
      (mPlaybackRate > 0 && EffectEnd() == TimeDuration::Forever())) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }

  AutoMutationBatchForAnimation mb(*this);

  // Seek to the end
  TimeDuration limit =
    mPlaybackRate > 0 ? TimeDuration(EffectEnd()) : TimeDuration(0);
  bool didChange = GetCurrentTime() != Nullable<TimeDuration>(limit);
  SilentlySetCurrentTime(limit);

  // If we are paused or play-pending we need to fill in the start time in
  // order to transition to the finished state.
  //
  // We only do this, however, if we have an active timeline. If we have an
  // inactive timeline we can't transition into the finished state just like
  // we can't transition to the running state (this finished state is really
  // a substate of the running state).
  if (mStartTime.IsNull() &&
      mTimeline &&
      !mTimeline->GetCurrentTime().IsNull()) {
    mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
                        limit.MultDouble(1.0 / mPlaybackRate));
    didChange = true;
  }

  // If we just resolved the start time for a pause or play-pending
  // animation, we need to clear the task. We don't do this as a branch of
  // the above however since we can have a play-pending animation with a
  // resolved start time if we aborted a pause operation.
  if (!mStartTime.IsNull() &&
      (mPendingState == PendingState::PlayPending ||
       mPendingState == PendingState::PausePending)) {
    if (mPendingState == PendingState::PausePending) {
      mHoldTime.SetNull();
    }
    CancelPendingTasks();
    didChange = true;
    if (mReady) {
      mReady->MaybeResolve(this);
    }
  }
  UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Sync);
  if (didChange && IsRelevant()) {
    nsNodeUtils::AnimationChanged(this);
  }
  PostUpdate();
}
开发者ID:prashant2018,项目名称:gecko-dev,代码行数:55,代码来源:Animation.cpp


示例6: GetCurrentTime

void
Animation::SilentlySetPlaybackRate(double aPlaybackRate)
{
  Nullable<TimeDuration> previousTime = GetCurrentTime();
  mPlaybackRate = aPlaybackRate;
  if (!previousTime.IsNull()) {
    ErrorResult rv;
    SilentlySetCurrentTime(previousTime.Value());
    MOZ_ASSERT(!rv.Failed(), "Should not assert for non-null time");
  }
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:11,代码来源:Animation.cpp


示例7:

void
AnimationPlayer::SetSource(Animation* aSource)
{
  if (mSource) {
    mSource->SetParentTime(Nullable<TimeDuration>());
  }
  mSource = aSource;
  if (mSource) {
    mSource->SetParentTime(GetCurrentTime());
  }
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:11,代码来源:AnimationPlayer.cpp


示例8: _GetThreadID

   void 
   Logger::LogEvent(const String &sMessage)
   {
      long lThread = _GetThreadID();
      String sTime = GetCurrentTime();

      String sData;
      sData.Format(_T("%d\t\"%s\"\t\"%s\"\r\n"), lThread, sTime, sMessage);

      _WriteData(sData, Events);
   }
开发者ID:bogri5520,项目名称:hMailServer,代码行数:11,代码来源:Logger.cpp


示例9: GetCurrentTime

void
Clock::Pause ()
{
 	//printf ("clock %p (%s) paused\n", this, GetName ());

	if (is_paused)
		return;

	is_paused = true;
	begin_pause_time = GetCurrentTime();
}
开发者ID:kangaroo,项目名称:moon,代码行数:11,代码来源:clock.cpp


示例10: SH_RobustAccept

/**
 * Performs a robust accept, restarting when interrupted.
 * Requires a valid socket (se->fd >= 0).
 */
extern int
SH_RobustAccept(SockEntry se) {
	int timeout = se->base->robustTimeout;
	uint64_t start = GetCurrentTime();
	for (;;) {
		int connRes = accept(se->fd, NULL, NULL);
		if (connRes >= 0) {
			se->lastUsed = GetCurrentTime();
			return connRes;
		}
		int e = errno;
		if (e != EAGAIN && e != EINTR) break;
		MilliSleep(RobustMillis);
		uint64_t now = GetCurrentTime();
		double dt = DeltaTime(start, now);
		if (dt > timeout) break;
	}
	se->errCount++;
	return -1;
}
开发者ID:cawka,项目名称:packaging-ndnx,代码行数:24,代码来源:SockHop.c


示例11: GetCurrentTime

// ProcessEvents
// called by the Process at interrupt time to see if there are
// any events that have timed out
//
void STREAM::ProcessEvents(void)
{
   if (qhEvent.IsElements()) {
      PEVENT pnextevent = (PEVENT)qhEvent.Head();
      ULONG time = GetCurrentTime();
      ULONG eventtime = pnextevent->GetEventTime();
      if (eventtime <= time)
         pnextevent->Report(time);
   }

}
开发者ID:OS2World,项目名称:DEV-SAMPLES-DRV-Audio_PDD-,代码行数:15,代码来源:stream.c


示例12: SH_RobustConnect

/**
 * Performs a robust connect, restarting when interrupted.
 * Requires a valid socket (se->fd >= 0).
 */
extern int
SH_RobustConnect(SockEntry se, struct sockaddr *sap) {
	int timeout = se->base->robustTimeout;
	uint64_t start = GetCurrentTime();
	for (;;) {
		int connRes = connect(se->fd, sap, SockAddrLen(sap));
		if (connRes >= 0) {
			se->lastUsed = GetCurrentTime();
			return connRes;
		}
		int e = errno;
		if (e != EAGAIN && e != EINTR) break;
		MilliSleep(RobustMillis);
		uint64_t now = GetCurrentTime();
		double dt = DeltaTime(start, now);
		if (dt > timeout) break;
	}
	se->errCount++;
	return -1;
}
开发者ID:cawka,项目名称:packaging-ndnx,代码行数:24,代码来源:SockHop.c


示例13: SysMouseAImpl_GetDeviceState

/******************************************************************************
  *     GetDeviceState : returns the "state" of the mouse.
  *
  *   For the moment, only the "standard" return structure (DIMOUSESTATE) is
  *   supported.
  */
static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
	LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) {
    SysMouseImpl *This = (SysMouseImpl *)iface;

    if(This->acquired == 0) return DIERR_NOTACQUIRED;

    EnterCriticalSection(&(This->crit));
    TRACE("(this=%p,0x%08lx,%p):\n", This, len, ptr);
    TRACE("(X: %ld - Y: %ld - Z: %ld  L: %02x M: %02x R: %02x)\n",
	  This->m_state.lX, This->m_state.lY, This->m_state.lZ,
	  This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
    
    /* Copy the current mouse state */
    fill_DataFormat(ptr, &(This->m_state), This->wine_df);
    
    /* Initialize the buffer when in relative mode */
    if (This->absolute == 0) {
	This->m_state.lX = 0;
	This->m_state.lY = 0;
	This->m_state.lZ = 0;
    }
    
    /* Check if we need to do a mouse warping */
    if (This->need_warp == WARP_NEEDED && (GetCurrentTime() - This->last_warped > 10)) {
	dinput_window_check(This);
	TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
	SetCursorPos( This->mapped_center.x, This->mapped_center.y );
        This->last_warped = GetCurrentTime();

#ifdef MOUSE_HACK
	This->need_warp = WARP_DONE;
#else
	This->need_warp = WARP_STARTED;
#endif
    }
    
    LeaveCriticalSection(&(This->crit));
    
    return DI_OK;
}
开发者ID:howard5888,项目名称:wineT,代码行数:47,代码来源:mouse.c


示例14: GetPlayerOwner

//------------------------------------------------------------------------------
// Purpose : Update weapon
//------------------------------------------------------------------------------
void CWeaponSDKMelee::ItemPostFrame( void )
{
	CSDKPlayer *pPlayer = GetPlayerOwner();
	if ( pPlayer == NULL )
		return;

	if (IsThrowingGrenade())
	{
		if (MaintainGrenadeToss())
			return;
	}
	else if ((pPlayer->m_nButtons & IN_ALT2) && !IsThrowingGrenade() && pPlayer->GetAmmoCount(GetAmmoDef()->Index("grenades")) && pPlayer->CanAttack())
	{
		bool bAllow = (m_flNextPrimaryAttack < GetCurrentTime());
		if (m_bInReload)
			bAllow = true;

		if (bAllow)
		{
			StartGrenadeToss();
			return;
		}
	}

	if (GetSwingTime() > 0 && GetSwingTime() <= GetCurrentTime())
	{
		Swing();
	}
	else if ( (pPlayer->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= GetCurrentTime()) && pPlayer->CanAttack() )
	{
		PrimaryAttack();
	} 
	else if ( (pPlayer->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= GetCurrentTime()) && pPlayer->CanAttack() )
	{
		SecondaryAttack();
	}
	else 
	{
		WeaponIdle();
	}
}
开发者ID:JorgeChimendes,项目名称:DoubleAction,代码行数:44,代码来源:sdk_weapon_melee.cpp


示例15: SH_NewSockEntryNoCheck

static SockEntry
SH_NewSockEntryNoCheck(SockBase base, int sockFD) {
	SockEntry ret = ProxyUtil_StructAlloc(1, SockEntryStruct);
	ret->base = base;
	ret->next = base->list;
	ret->fd = sockFD;
	ret->startTime = GetCurrentTime();
	ret->lastUsed = ret->startTime;
	base->list = ret;
	base->nSocks++;
	return ret;
}
开发者ID:cawka,项目名称:packaging-ndnx,代码行数:12,代码来源:SockHop.c


示例16: SH_RobustSendmsg

/**
 * Performs a robust sendmsg, restarting when interrupted.
 * Requires a connection.
 */
extern ssize_t
SH_RobustSendmsg(SockEntry se, struct msghdr *mp) {
	int timeout = se->base->robustTimeout;
	uint64_t start = GetCurrentTime();
	for (;;) {
		ssize_t nb = sendmsg(se->fd, mp, 0);
		if (nb >= 0) {
			se->writeActive = 1;
			se->lastUsed = GetCurrentTime();
			return nb;
		}
		int e = errno;
		if (e != EAGAIN && e != EINTR) break;
		MilliSleep(RobustMillis);
		uint64_t now = GetCurrentTime();
		double dt = DeltaTime(start, now);
		if (dt > timeout) break;
	}
	se->errCount++;
	return -1;
}
开发者ID:cawka,项目名称:packaging-ndnx,代码行数:25,代码来源:SockHop.c


示例17: dprintf

ULONG  WAVESTREAM::StopStream(PCONTROL_PARM pControl)
{
   if(ulStreamState == STREAM_STOPPED) {
   	dprintf(("WAVESTREAM::StopStream %lx (already stopped)", ulStreamId));
   	fUnderrun = FALSE;
   	pControl->ulTime = GetCurrentTime();
	return NO_ERROR;
   }
   pahw->Stop(this);
   //Reset cleans up waveout instance
   OSS16_StreamReset(this);

   ulStreamState = STREAM_STOPPED;
   fUnderrun = FALSE;
   dprintf(("WAVESTREAM::StopStream %lx", ulStreamId));
   ReturnBuffers();
   pControl->ulTime = GetCurrentTime();
   _ulTimeBase = GetCurrentTime();
   return NO_ERROR;

}
开发者ID:OS2World,项目名称:DRV-SBLiveOS2,代码行数:21,代码来源:wavestrm.cpp


示例18: GetCurrentTime

  int Timer::DelayIsComplete (const Time& delay, bool reset)
  {
    float currentTime = GetCurrentTime ().GetValue ();

    int factor = static_cast<int> (
      currentTime / delay.GetValue ());

    if (reset && factor > 0)
      Reset (Time (currentTime - factor * delay.GetValue ()));

    return factor;
  }
开发者ID:Noxalus,项目名称:YAPOG,代码行数:12,代码来源:Timer.cpp


示例19: sprintf

int CAppLoger::Init(const std::string& strPath, const std::string&  strLogFileName, const int&  iLogLevel)
{
	if(strPath.empty())
	{
		m_strLogPath = ".";
	}
	else
	{
		//暂时不支持路径处理,待后期维护
		//这是一个坑吗?
		//
		m_strLogPath = strPath;
	}
	//待完成
	//以时间戳和pid作为默认文件名
	if(strLogFileName.empty())
	{
		char szTmp[128] = {'0'};
		sprintf(szTmp, "%d", getpid());
		std::string strTmp(szTmp);
		//m_strLogFileName = strTmp+"_"+GetCurrentTime().replace(10,1, "_")+".log";
		std::string strTmpTime = GetCurrentTime();
		std::string strFromatTime="";
		for(std::string::iterator it = strTmpTime.begin(); it != strTmpTime.end(); it++)
		{
			if(*it == '_' || *it == '-' || *it == ' ' || *it == ':')
			{
				continue;
			}

			strFromatTime.push_back((*it));
		}

		m_strLogFileName = strTmp +"-"+strFromatTime + ".log";
	}
	else
	{
		m_strLogFileName = strLogFileName;
	}

	if(iLogLevel > INF)
	{
		std::cout<<"this level "<< iLogLevel << "is so large"<<std::endl;
		return RUN_ERROR;
	}
	else
	{
		m_iLogLevel = iLogLevel;
	}

	return RUN_OK;

}
开发者ID:mfslog,项目名称:Code,代码行数:53,代码来源:AppLoger.cpp


示例20: GetCurrentTime

void CPerformanceAnalysis::StartTiming()
{
    int hour, minute, second, msecond;

    GetCurrentTime(hour, minute, second);
    GetPreciseCurrentTime(msecond);

    m_Functions[m_CurrentFunction].ExecutionTime.Hour = hour;
    m_Functions[m_CurrentFunction].ExecutionTime.Minute = minute;
    m_Functions[m_CurrentFunction].ExecutionTime.Second = second;
    m_Functions[m_CurrentFunction].ExecutionTime.Millisecond = msecond;
}
开发者ID:jmfrouin,项目名称:gnulinux-sdatabase,代码行数:12,代码来源:performance_analysis.cpp



注:本文中的GetCurrentTime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetCurrentTimestamp函数代码示例发布时间:2022-05-30
下一篇:
C++ GetCurrentThreadId函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap