time.cpp

来自「用于机器人自动低分辨路的地图测绘程序。用于机器人控制测绘。分为远端控制端和本地控」· C++ 代码 · 共 51 行

CPP
51
字号
/*
    Robot Interface
    (C) 2006 Jason Hunt
    nulluser@gmail.com
    
    File: time.cpp
*/

#include <windows.h>


CRITICAL_SECTION time_lock;

void time_start( void )
{
    InitializeCriticalSection(&time_lock);       
}



/* Return current time in seconds */
double get_time( void )
{
    EnterCriticalSection(&time_lock);           

    static LARGE_INTEGER freq;
    bool init = 0;

    if (!init)
    {
        QueryPerformanceFrequency(&freq);
        init = 1;
    }

    LARGE_INTEGER c;

    QueryPerformanceCounter(&c);

    double value = c.QuadPart / (double)freq.QuadPart;
    
    LeaveCriticalSection(&time_lock);
    
    return(value);
}
/* End of get_time */





⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?