rdtsc时间戳

【tsc】

time stamp counter

【性能】

大概只要chrono接口的1/6时延

【测试程序】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <x86intrin.h>
#include <chrono>
#include <cstdio>
 
using namespace std::chrono;
int main(){
    u_int64_t begin = duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
    for(int i=0;i<100000;i++){
        u_int64_t a = __rdtsc();
//        u_int64_t a = duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
    }
    u_int64_t end = duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count();
    printf("time_elapsed=%llu\n", end - begin);
    return 0;
}

  

 

posted @   stupidstan2019  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
历史上的今天:
2022-02-13 【事务】谓词锁(predictiveLock)
2022-02-13 【事务】ssi
2022-02-13 【事务】幻读
2022-02-13 【事务】可重复读串行话更新失败
点击右上角即可分享
微信分享提示