Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 36 lines (33 sloc) 1.211 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
'|--------------------------------------------------------|
'| VERY PRECISE TIMER TO USE FOR DEBUGGING RUNS FOR SPEED |
'|--------------------------------------------------------|
' TAKEN FROM: http://stackoverflow.com/questions/198409/how-do-you-test-running-time-of-vba-code
' USE WITH: CLASS MODULE QueryPerformanceCounter

Sub TimeDebbugger()
    Dim Timer As QueryPerformanceCounter
    Dim i As Long, j As Long
    Dim Output As Variant
    Dim TimeValue As Double
    Dim TimeCounter As Long
    Dim NumAveragingPeriods As Integer
    Dim NumberFunctionCalls As Integer

    NumAveragingPeriods = 2500
    NumberFunctionCalls = 2500

    'set timer options
    TimeValue = 0
    Set Timer = New QueryPerformanceCounter
    Timer.StartCounter
    For i = 1 To NumAveragingPeriods
        For j = 1 To NumberFunctionCalls
            '|----------------------|
            '| CALL A FUNCTION HERE |
            '|----------------------|
            Output = ColumnLetter(j)
'|----------------------|
'|----------------------|
'|----------------------|
        Next j
        TimeValue = Timer.TimeElapsed
    Next i
    Debug.Print "Average Time = " & TimeValue / NumAveragingPeriods
End Sub
Something went wrong with that request. Please try again.