BOOL QueryPerformanceCounter(
LARGE_INTEGER *lpPerformanceCount // pointer to counter value
);
Parameters
lpPerformanceCount
Pointer to a variable that the function sets, in counts, to the current performance-counter value. If the installed hardware does not support a high-resolution performance counter, this parameter can be to zero.
Return Values
If the installed hardware supports a high-resolution performance counter, the return value is nonzero.
If the installed hardware does not support a high-resolution performance counter, the return value is zero.
(中文譯文:
函式QueryPerformanceCounter用於得到高精度計時器的值(如果存在這樣的計時器)
BOOL QueryPerformanceCounter(LARGE_INTEGER *ipPerformanceCount);//參數指向計數器的值
參數LARGE_INTEGER *ipProformanceCount
為一個指針變數用於函式傳值,即指向現時計數器的值.如果安裝的硬體不支持高精度計時器,該參數將返回0,
關於返回值:
如果安裝的硬體支持高精度計時器,函式將返回非0值.
如果安裝的硬體不支持高精度計時器,函式將返回0.
)
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: unsupported.
Header: declared in winbase.h.
Import Library: Use kernel32.lib.
計時代碼以查明性能瓶頸, 時要使用系統有以提供高解析度計時器。 下例介紹如何使用 QueryPerformanceCounter 函式以應用程式代碼。
輸入下列代碼插入模組。 如果類、, 窗體或報表模組, 中輸入它使聲明 Private。
Option Explicit
Declare Function QueryPerformanceCounter Lib "Kernel32" _
(X As Currency) As Boolean
Declare Function QueryPerformanceFrequency Lib "Kernel32" _
(X As Currency) As Boolean
Declare Function GetTickCount Lib "Kernel32" () As Long
Declare Function timeGetTime Lib "winmm.dll" () As Long
Sub Test_Timers()
Dim Ctr1 As Currency, Ctr2 As Currency, Freq As Currency
Dim Count1 As Long, Count2 As Long, Loops As Long
'
' Time QueryPerformanceCounter
'
If QueryPerformanceCounter(Ctr1) Then
QueryPerformanceCounter Ctr2
Debug.Print "Start Value: "; Format$(Ctr1, "0.0000")
Debug.Print "End Value: "; Format$(Ctr2, "0.0000")
QueryPerformanceFrequency Freq
Debug.Print "QueryPerformanceCounter minimum resolution: 1/" & _
Freq * 10000; " sec"
Debug.Print "API Overhead: "; (Ctr2 - Ctr1) / Freq; "seconds"
Else
Debug.Print "High-resolution counter not supported."
End If
'
' Time GetTickCount
'
Debug.Print
Loops = 0
Count1 = GetTickCount()
Do
Count2 = GetTickCount()
Loops = Loops + 1
Loop Until Count1 <> Count2
Debug.Print "GetTickCount minimum resolution: "; _
(Count2 - Count1); "ms"
Debug.Print "took"; Loops; "loops"
'
' Time timeGetTime
'
Debug.Print
Loops = 0
Count1 = timeGetTime()
Do
Count2 = timeGetTime()
Loops = Loops + 1
Loop Until Count1 <> Count2
Debug.Print "timeGetTime minimum resolution: "; _
(Count2 - Count1); "ms"
Debug.Print "Took"; Loops; "loops"
End Sub
相關詞條
-
QueryPerformanceCounter
ceCoun ter ceCoun
-
QueryPerformanceCounter function
_Out_
構造 -
Win32多執行緒
Win32 多執行緒的性能:作者:Microsoft公司供稿Ruediger R. Asche摘要本文討論將單執行緒應用程式重新編寫...
Win32 多執行緒的性能: 摘要 介紹 多執行緒辭彙 基於CPU的計算和基於I/O的計算 -
QueryPerformanceFrequency()
()和QueryPerformanceCounter(),要求計算機... QueryPerformanceCounter (LARGE_INTEGER *lpCount); 數據類型...QueryPerformanceCounter(),利用兩次獲得的計數之差和時鐘頻率,就可以...
基本介紹 技術特點 套用平台 發展歷程 相關技術 -
timeGetTime
。QueryPerformanceCounter和...
簡介 VB 聲明 返回值 參數 備註 -
oop
面向對象編程(Object Oriented Programming,OOP,面向對象程式設計)是一種計算機編程架構。OOP...
一、oop的基本思想 二、OOP技術的歷史 三、OOP 的優缺點 -
virtools
QueryPerformanceCounter,藉以傳回正確的數值。由於...
歷史發展 前途發展 系統需求 執行流程 最新功能 -
kernel32.dll
檔案信息 kernel32.dll 軟體大小:隨作業系統版本不同而不同軟體星級:2.5檔案描述:Windows NT BASE ...
檔案信息 核心檔案 出錯元兇 解決方案 技術信息 -
變速齒輪
機械裝置變速齒輪包括普通外嚙合變速齒輪、普通內嚙合變速齒輪及行星變速齒輪。行星變速齒輪在輪式工程機械輪邊減速器中的行星變速齒輪機...
機械裝置 程式