<legend id='5qFM4'><style id='5qFM4'><dir id='5qFM4'><q id='5qFM4'></q></dir></style></legend>

      • <bdo id='5qFM4'></bdo><ul id='5qFM4'></ul>

    1. <i id='5qFM4'><tr id='5qFM4'><dt id='5qFM4'><q id='5qFM4'><span id='5qFM4'><b id='5qFM4'><form id='5qFM4'><ins id='5qFM4'></ins><ul id='5qFM4'></ul><sub id='5qFM4'></sub></form><legend id='5qFM4'></legend><bdo id='5qFM4'><pre id='5qFM4'><center id='5qFM4'></center></pre></bdo></b><th id='5qFM4'></th></span></q></dt></tr></i><div id='5qFM4'><tfoot id='5qFM4'></tfoot><dl id='5qFM4'><fieldset id='5qFM4'></fieldset></dl></div>

      <small id='5qFM4'></small><noframes id='5qFM4'>

      <tfoot id='5qFM4'></tfoot>

      1. C++ 跨平台高分辨率定时器

        C++ Cross-Platform High-Resolution Timer(C++ 跨平台高分辨率定时器)
      2. <small id='aNmjC'></small><noframes id='aNmjC'>

          <bdo id='aNmjC'></bdo><ul id='aNmjC'></ul>
            <tbody id='aNmjC'></tbody>

          • <i id='aNmjC'><tr id='aNmjC'><dt id='aNmjC'><q id='aNmjC'><span id='aNmjC'><b id='aNmjC'><form id='aNmjC'><ins id='aNmjC'></ins><ul id='aNmjC'></ul><sub id='aNmjC'></sub></form><legend id='aNmjC'></legend><bdo id='aNmjC'><pre id='aNmjC'><center id='aNmjC'></center></pre></bdo></b><th id='aNmjC'></th></span></q></dt></tr></i><div id='aNmjC'><tfoot id='aNmjC'></tfoot><dl id='aNmjC'><fieldset id='aNmjC'></fieldset></dl></div>

              • <legend id='aNmjC'><style id='aNmjC'><dir id='aNmjC'><q id='aNmjC'></q></dir></style></legend>
                <tfoot id='aNmjC'></tfoot>
                  本文介绍了C++ 跨平台高分辨率定时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我希望在 C++ 中实现一个简单的计时器机制.该代码应该适用于 Windows 和 Linux.分辨率应尽可能精确(至少毫秒精度).这将用于简单地跟踪时间的流逝,而不是实现任何类型的事件驱动设计.实现这一目标的最佳工具是什么?

                  I'm looking to implement a simple timer mechanism in C++. The code should work in Windows and Linux. The resolution should be as precise as possible (at least millisecond accuracy). This will be used to simply track the passage of time, not to implement any kind of event-driven design. What is the best tool to accomplish this?

                  推荐答案

                  对于 C++03:

                  Boost.Timer 可能有用,但它取决于 C 函数 clock,因此可能没有足够好的分辨率.

                  Boost.Timer might work, but it depends on the C function clock and so may not have good enough resolution for you.

                  Boost.Date_Time 包括一个 ptime class 之前在 Stack Overflow 上被推荐过.请参阅其关于 microsec_clock::local_timemicrosec_clock::universal_time 的文档,但请注意其警告Win32 系统通常无法通过此 API 实现微秒分辨率."

                  Boost.Date_Time includes a ptime class that's been recommended on Stack Overflow before. See its docs on microsec_clock::local_time and microsec_clock::universal_time, but note its caveat that "Win32 systems often do not achieve microsecond resolution via this API."

                  STLsoft 提供了围绕 OS 的瘦跨平台(Windows 和 Linux/Unix)C++ 包装器等.特定的 API.它的 性能库 有几个类可以满足您的需求.(要使其跨平台,请选择一个在 winstlunixstl 命名空间中都存在的类似 performance_counter 的类,然后使用与您的平台匹配的命名空间.)

                  STLsoft provides, among other things, thin cross-platform (Windows and Linux/Unix) C++ wrappers around OS-specific APIs. Its performance library has several classes that would do what you need. (To make it cross platform, pick a class like performance_counter that exists in both the winstl and unixstl namespaces, then use whichever namespace matches your platform.)

                  对于 C++11 及更高版本:

                  std::chrono 库内置了此功能.请参阅此答案@HowardHinnant 了解详情.

                  The std::chrono library has this functionality built in. See this answer by @HowardHinnant for details.

                  这篇关于C++ 跨平台高分辨率定时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                  Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                  Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                  Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                  How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                  Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)

                1. <i id='MF6sf'><tr id='MF6sf'><dt id='MF6sf'><q id='MF6sf'><span id='MF6sf'><b id='MF6sf'><form id='MF6sf'><ins id='MF6sf'></ins><ul id='MF6sf'></ul><sub id='MF6sf'></sub></form><legend id='MF6sf'></legend><bdo id='MF6sf'><pre id='MF6sf'><center id='MF6sf'></center></pre></bdo></b><th id='MF6sf'></th></span></q></dt></tr></i><div id='MF6sf'><tfoot id='MF6sf'></tfoot><dl id='MF6sf'><fieldset id='MF6sf'></fieldset></dl></div>
                    <tbody id='MF6sf'></tbody>
                    • <tfoot id='MF6sf'></tfoot>

                      <small id='MF6sf'></small><noframes id='MF6sf'>

                      • <legend id='MF6sf'><style id='MF6sf'><dir id='MF6sf'><q id='MF6sf'></q></dir></style></legend>
                        • <bdo id='MF6sf'></bdo><ul id='MF6sf'></ul>