久久久久久久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 排序功能對列表進行排序)
主站蜘蛛池模板: 亚洲看片 | 毛片网站在线播放 | 手机av在线 | 成人看 | 五月天一区二区三区 | 国产精品一区二区久久 | 免费一区二区三区 | 99精品欧美一区二区蜜桃免费 | 亚洲性天堂 | 午夜aaa| 亚洲国产成人精品女人久久久 | 亚洲欧美久久 | 国产伦精品一区二区三毛 | 国产成人区 | 日韩免费看片 | 欧美另类z0zx974| 国产乱轮视频 | 少妇特黄a一区二区三区 | 在线观看免费av网站 | 国产午夜一区二区三区 | 免费在线小视频 | 日韩爱爱视频 | 日韩一级视频 | 国产欧美日韩在线视频 | 日韩精品免费在线观看 | 日韩专区中文字幕 | 免费特级毛片 | 伊人免费视频 | 国产欧美日韩一区 | 在线观看亚洲一区 | 国产精品99久久久久久久久 | 日本精品视频在线观看 | 人人干人人草 | 亚洲人在线观看 | 中国第一毛片 | 在线不卡av | 国产精品久久视频 | 日韩免费一区二区三区 | 欧美理伦 | 五月天一区二区 | 成人性色生活片 |