小编use*_*660的帖子

我在 Linux 上可以获得的最佳时序分辨率是多少

我正在尝试测量并行端口上 2 个信号之间的时间差,但首先我要知道我的测量系统(AMD Athlon(tm) 64 X2 双核处理器 5200+ \xc3\x97 2) 在 SUSE 12.1 x64 上。

\n\n

因此,经过一番阅读后,我决定使用clock_gettime(),首先我使用以下代码获取clock_getres()值:

\n\n
/*\n * This program prints out the clock resolution.\n */\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n\nint main( void )\n  {\n    struct timespec res;\n\n    if ( clock_getres( CLOCK_REALTIME, &res) == -1 ) {\n      perror( "clock get resolution" );\n      return EXIT_FAILURE;\n    }\n    printf( "Resolution is %ld nano seconds.\\n",\n          res.tv_nsec);\n    return EXIT_SUCCESS;\n  }\n
Run Code Online (Sandbox Code Playgroud)\n\n

结果是:1 纳秒。我很高兴!

\n\n

但这是我的问题,当我尝试用其他代码检查这一事实时:

\n\n
#include <iostream>\n#include <time.h>\nusing namespace std;\n\ntimespec diff(timespec start, timespec end);\n\nint …
Run Code Online (Sandbox Code Playgroud)

c++ resolution timing

2
推荐指数
1
解决办法
9506
查看次数

标签 统计

c++ ×1

resolution ×1

timing ×1