1. 常用功能

1.1. 睡眠

#include <chrono>
#include <thread>

void main(){
    std::this_thread::sleep_for(std::chrono:: milliseconds (1000)); //休眠1000毫秒
}

1.2. 获得当前程序运行毫秒

#include <ctime>
void main(){
    int tick=(int)(std::clock()*1000/ CLOCKS_PER_SEC);
}

1.3. 计时

#include <chrono>
#include <thread>

void main(){
    auto start = high_resolution_clock::now();
    std::this_thread::sleep_for(std::chrono:: milliseconds (2000));
    auto end = high_resolution_clock::now();
    duration_cast<microseconds>(end - start).count();
}
Copyright © ershouche-FE 2019 all right reserved,powered by Gitbook文件修订时间: 2022-02-28 22:58:38

results matching ""

    No results matching ""