久久久久久久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 排序功能對列表進行排序)
主站蜘蛛池模板: 亚洲一区二区三区免费观看 | 福利一区视频 | 午夜ww| 国产在线不卡视频 | 久久国产一区二区 | 亚洲欧美日韩精品久久亚洲区 | 一区二区三区视频播放 | 97国产精品| 欧州一区 | 中文久久| 亚洲精品一二三区 | 午夜免费福利电影 | 亚洲欧美国产一区二区三区 | 久久精品视频在线观看 | 日韩精品一区二区三区四区视频 | 欧美日韩在线一区二区 | 久久久久久亚洲精品 | 欧美在线视频一区二区 | 久久免费视频观看 | av大片 | 亚洲成人av| 99视频在线看 | 亚洲成人三级 | 嫩草研究影院 | 美女久久久久久久 | 日韩中文字幕在线观看 | 久久久久久久久久久久91 | 天天综合久久 | 国产一区二区三区免费 | 国产欧美日韩在线播放 | 国产一区二区三区久久久久久久久 | 国产在线播放一区二区三区 | 秋霞a级毛片在线看 | 超级碰在线 | 精品福利一区二区三区 | 亚洲第1页 | 成年人黄色一级毛片 | 黄色一级大片在线免费看产 | 亚洲色欲色欲www | 亚洲成人精品在线观看 | 自拍偷拍亚洲一区 |