久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Windows中的C++高精度時間測量

C++ high precision time measurement in Windows(Windows中的C++高精度時間測量)
本文介紹了Windows中的C++高精度時間測量的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我對在 Windows 中使用 C++ 測量精確到納秒的特定時間點很感興趣.這可能嗎?如果不是,是否可以至少以微秒為單位獲得特定時間?任何庫都應該這樣做,除非我認為托管代碼是可能的.謝謝

I'm interested in measuring a specific point in time down to the nanosecond using C++ in Windows. Is this possible? If it isn't, is it possible to get the specific time in microseconds at least?. Any library should do, unless I suppose it's possible with managed code. thanks

推薦答案

如果您有一個線程應用程序在多核計算機上運行 QueryPerformanceCounter 可以(并將)根據代碼的內核返回不同的值正在執行.請參閱這篇 MSDN 文章.(rdtsc 也有同樣的問題)

If you have a threaded application running on a multicore computer QueryPerformanceCounter can (and will) return different values depending on which core the code is executing on. See this MSDN article. (rdtsc has the same problem)

這不僅僅是一個理論問題;我們在我們的應用程序中遇到了它,并且不得不得出結論,唯一可靠的時間源是 timeGetTime ,它只有 ms 精度(幸運的是,在我們的例子中已經足夠了).我們還嘗試為我們的線程固定線程關聯,以保證每個線程始終從 QueryPerformanceCounter 獲得一致的值,這有效,但它絕對降低了應用程序的性能.

This is not just a theoretical problem; we ran into it with our application and had to conclude that the only reliable time source is timeGetTime which only has ms precision (which fortunately was sufficient in our case). We also tried fixating the thread affinity for our threads to guarantee that each thread always got a consistent value from QueryPerformanceCounter, this worked but it absolutely killed the performance in the application.

總而言之,Windows 上沒有一個可靠計時器可以用于以微秒精度計時(至少在多核計算機上運行時不會).

To sum things up there isn't a reliable timer on windows that can be used to time thing with micro second precision (at least not when running on a multicore computer).

這篇關于Windows中的C++高精度時間測量的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What is the fastest way to transpose a matrix in C++?(在 C++ 中轉置矩陣的最快方法是什么?)
Sorting zipped (locked) containers in C++ using boost or the STL(使用 boost 或 STL 在 C++ 中對壓縮(鎖定)容器進行排序)
Rotating a point about another point (2D)(圍繞另一個點旋轉一個點 (2D))
Image Processing: Algorithm Improvement for #39;Coca-Cola Can#39; Recognition(圖像處理:Coca-Cola Can 識別的算法改進)
How do I construct an ISO 8601 datetime in C++?(如何在 C++ 中構建 ISO 8601 日期時間?)
Sort list using STL sort function(使用 STL 排序功能對列表進行排序)
主站蜘蛛池模板: 精品入口麻豆88视频 | 亚洲一区二区久久 | 日韩在线日韩 | 日韩免费三级 | 97avcc| 日韩福利 | 久久久久国产一区二区三区四区 | 中文字幕欧美日韩一区 | 精品一区二区三区日本 | 久久久精品网 | 岛国av免费看 | 天天干天天干 | 亚洲日韩中文字幕一区 | 伊色综合久久之综合久久 | 成人黄色av | 老司机深夜福利网站 | 观看av| 日韩欧美一区二区三区 | 免费看a| 日本久久精品 | 中文字幕一区二区三区乱码在线 | 国内自拍真实伦在线观看 | 午夜影院在线观看版 | 久久久国产一区二区三区 | 狠狠操网站 | 日韩欧美一区二区三区在线播放 | 国产精品视频网 | 欧美日韩精品久久久免费观看 | 国产在线播 | 麻豆精品国产免费 | 欧洲成人免费视频 | 日韩无| 国产超碰人人爽人人做人人爱 | 视频一区在线 | 久久精品亚洲精品国产欧美kt∨ | 美女三区| 国产视频线观看永久免费 | 在线精品国产 | www.亚洲精品| 特级毛片 | 有码在线 |