Разница во времени с точностью до милисекунд (API)По материалам: https://www.aeternusconsulting.com/best-millisecond-timer-vba/ #If VBA7 And Win64 Then ' Performance counter API's 'for 64-bit Excel Declare PtrSafe Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long Declare PtrSafe Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long #Else 'for 32-bit Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long #End If '*********************************************************** 'Purpose: Measure elapsed time in milliseconds '*********************************************************** Sub MilliSecondTimer_Start() Dim lgResult As Long lgResult = QueryPerformanceCounter(curStartCounter) End Sub '*********************************************************** 'Purpose: Measure elapsed time in milliseconds '*********************************************************** Sub MilliSecondTimer_End() Dim lgResult As Long Dim curFrequency As Currency lgResult = QueryPerformanceCounter(curEndCounter) lgResult = QueryPerformanceFrequency(curFrequency) Debug.Print "Elapsed time (ms): " & (curEndCounter - curStartCounter) / curFrequency End Sub
'*********************************************************** 'Purpose: Sample code to measure elapsed time in milliseconds '*********************************************************** Sub TimeACode() 'measure start count Call MilliSecondTimer_Start '***************************************** 'Insert the code to measure elapsed time '***************************************** Dim lgCounter As Long For lgCounter = 1 To 100000000 'do nothing Next 'measure end count Call MilliSecondTimer_End End Sub
Call MilliSecondTimer_Start
Call MilliSecondTimer_End |
|||
L.E. 23.06.2023 |