Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize High Precision and perfect delay in easy language

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the easy language how to achieve high-precision perfect delay, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

DLL command table

. Version 2.DLL command QueryPerformanceCounter, integer, "kernel32", "QueryPerformanceCounter", get the count value. Parameter lpPerformanceCount, LARGE_INTEGER.DLL command QueryPerformanceFrequency, integer, "kernel32", "QueryPerformanceFrequency", returns the counting frequency. Parameter lpFrequency, LARGE_INTEGER

Custom data type table

. Version 2. Data type LARGE_INTEGER. Member QuadPart, integer type

High precision delay source code

. Version 2. Assembly window assembly 1. The subroutine _ _ startup window _ creates a real high-precision delay of (1000) 'delay of 1 millisecond. The real high-precision delay of the subroutine. Parameter delay time, integer, microsecond, 1000 microsecond = 1 millisecond, 1000 millisecond = 1 second. Local variables CurrTicks, LARGE_INTEGER. The local variable TicksCount, LARGE_INTEGERQueryPerformanceFrequency (TicksCount) QueryPerformanceCounter (CurrTicks) 'must be of the LARGE_INTEGER data type. If it is written as an integer directly, it will not run TicksCount.QuadPart = TicksCount.QuadPart × the time to be delayed / 1000000TicksCount.QuadPart = TicksCount.QuadPart + CurrTicks.QuadPart. Judge the head of the cycle (CurrTicks.QuadPart < TicksCount.QuadPart) QueryPerformanceCounter (CurrTicks). To judge the loop tail () 'High precision delay is the basis of CPU speed measurement.' there is a timer with very high precision in the Windows with a precision of microseconds, but the frequency of this timer varies with different systems, and this frequency may be related to both hardware and operating system.' The frequency of this timer can be obtained by using the API function QueryPerformanceFrequency.' The current value of the timer can be obtained by using the API function QueryPerformanceCounter. According to the time to be delayed and the frequency of the timer, the number of cycles passed by the timer to be delayed can be calculated.' In the loop, QueryPerformanceCounter is used to continuously read out the timer value until the specified number of cycles has passed before ending the cycle, thus achieving the purpose of high precision delay. Thank you for reading this article carefully. I hope the article "how to achieve high precision and perfect delay in easy language" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report