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

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

  • <small id='5B6hd'></small><noframes id='5B6hd'>

    1. <legend id='5B6hd'><style id='5B6hd'><dir id='5B6hd'><q id='5B6hd'></q></dir></style></legend>

        <bdo id='5B6hd'></bdo><ul id='5B6hd'></ul>
      1. 最快的时序解析系统

        Fastest timing resolution system(最快的时序解析系统)
        1. <small id='n8Bi2'></small><noframes id='n8Bi2'>

            • <tfoot id='n8Bi2'></tfoot>
                <bdo id='n8Bi2'></bdo><ul id='n8Bi2'></ul>
                1. <i id='n8Bi2'><tr id='n8Bi2'><dt id='n8Bi2'><q id='n8Bi2'><span id='n8Bi2'><b id='n8Bi2'><form id='n8Bi2'><ins id='n8Bi2'></ins><ul id='n8Bi2'></ul><sub id='n8Bi2'></sub></form><legend id='n8Bi2'></legend><bdo id='n8Bi2'><pre id='n8Bi2'><center id='n8Bi2'></center></pre></bdo></b><th id='n8Bi2'></th></span></q></dt></tr></i><div id='n8Bi2'><tfoot id='n8Bi2'></tfoot><dl id='n8Bi2'><fieldset id='n8Bi2'></fieldset></dl></div>
                    <tbody id='n8Bi2'></tbody>
                  <legend id='n8Bi2'><style id='n8Bi2'><dir id='n8Bi2'><q id='n8Bi2'></q></dir></style></legend>
                  本文介绍了最快的时序解析系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  C/C++ 程序员可以使用的最快计时系统是什么?

                  例如:
                  time() 将给出自 1970 年 1 月 1 日 00:00 以来的秒数.
                  Windows 上的 GetTickCount() 将给出自系统启动以来的时间(以毫秒为单位),但限制为 49.7 天(之后它会简单地回零).

                  我想以毫秒为单位获取当前时间或自系统/应用程序启动以来的滴答声.

                  最大的问题是方法的开销 - 我需要最轻的一个,因为我将要每秒调用它很多次.

                  我的情况是我有一个工作线程,并且我向该工作线程发布了待处理的工作.每个作业都有一个执行时间".所以,我不在乎时间是当前的真实"时间还是自系统正常运行以来的时间 - 它必须是线性的和轻量级的.

                  unsigned __int64 GetTickCountEx(){静态 DWORD dwWraps = 0;静态 DWORD dwLast = 0;DWORD dwCurrent = 0;timeMutex.lock();dwCurrent = GetTickCount();如果(dwLast > dwCurrent)dwWraps++;dwLast = dwCurrent;无符号 __int64 时间结果 = ((无符号 __int64)0xFFFFFFFF * dwWraps) + dwCurrent;timeMutex.unlock();返回时间结果;}

                  解决方案

                  为了计时,当前微软推荐是使用QueryPerformanceCounter &QueryPerformanceFrequency.

                  这将为您提供优于毫秒的计时.如果系统不支持高分辨率计时器,则默认为毫秒(与 GetTickCount 相同).

                  这是一篇简短的 Microsoft 文章,其中包含您应该使用它的原因的示例 :)

                  What is the fastest timing system a C/C++ programmer can use?

                  For example:
                  time() will give the seconds since Jan 01 1970 00:00.
                  GetTickCount() on Windows will give the time, in milliseconds, since the system's start-up time, but is limited to 49.7 days (after that it simply wraps back to zero).

                  I want to get the current time, or ticks since system/app start-up time, in milliseconds.

                  The biggest concern is the method's overhead - I need the lightest one, because I'm about to call it many many times per second.

                  My case is that I have a worker thread, and to that worker thread I post pending jobs. Each job has an "execution time". So, I don't care if the time is the current "real" time or the time since the system's uptime - it just must be linear and light.

                  Edit:

                  unsigned __int64 GetTickCountEx()
                  {
                      static DWORD dwWraps = 0;
                      static DWORD dwLast = 0;
                  
                      DWORD dwCurrent = 0;
                  
                      timeMutex.lock();
                  
                      dwCurrent = GetTickCount();
                      if(dwLast > dwCurrent)
                          dwWraps++;
                  
                      dwLast = dwCurrent;
                  
                      unsigned __int64 timeResult = ((unsigned __int64)0xFFFFFFFF * dwWraps) + dwCurrent;
                  
                      timeMutex.unlock();
                  
                      return timeResult;
                  }
                  

                  解决方案

                  For timing, the current Microsoft recommendation is to use QueryPerformanceCounter & QueryPerformanceFrequency.

                  This will give you better-than-millisecond timing. If the system doesn't support a high-resolution timer, then it will default to milliseconds (the same as GetTickCount).

                  Here is a short Microsoft article with examples of why you should use it :)

                  这篇关于最快的时序解析系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to print vector#39;s data(如何打印矢量的数据)
                  Visual C++ appends 0xCC (int3) bytes at the end of functions(Visual C++ 在函数末尾附加 0xCC (int3) 字节)
                  How to use a variable inside a _T wrapper?(如何在 _T 包装器中使用变量?)
                  MSVC++ warning flags(MSVC++ 警告标志)
                  How to read file which contains uxxxx in vc++(如何在vc++中读取包含uxxxx的文件)
                  stack overflow error in C++ program(C++程序中的堆栈溢出错误)

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

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

                            <bdo id='vqxle'></bdo><ul id='vqxle'></ul>