Quick start - danielep71/VBA-Performance_Manager GitHub Wiki

Quick Start

This page gives you the first working timing example for cPerformanceManager.

First working example

Create a standard module and paste this code into it:

Option Explicit

Public Sub QuickStart_FirstTimingExample()

    Dim cPM         As cPerformanceManager
    Dim ElapsedS    As Double

    Set cPM = New cPerformanceManager

    cPM.StartTimer 5

    Range("A1:A10000").Value = 1

    ElapsedS = cPM.ElapsedSeconds

    Debug.Print "Method        : "; cPM.MethodName(cPM.ActiveMethodID)
    Debug.Print "Elapsed (sec) : "; Format$(ElapsedS, "0.000000000")
    Debug.Print "Elapsed (txt) : "; cPM.ElapsedTime

    cPM.ResetEnvironment
    Set cPM = Nothing

End Sub

What this example demonstrates

  • method 5 (QPC) is the recommended benchmark backend
  • ElapsedSeconds is the main numeric timing surface
  • ElapsedTime is the display/reporting companion
  • ResetEnvironment is the explicit cleanup contract

Next steps

After the first example works, continue with: