Hi All,

I am looking for a way to measure how long it takes to complete a sub routine in VBA. I have code which posts data to matlab and then calls it back. What I need to know is how long does it take to complete each subroutine.

Can anyone help me create a code which will measure this? I need to measure the time taken in 100ths of a second.

Is there any simple code to complete this? I am pasting a sample of my code which is using Matlab as a COM server.

I am sure I woould need to declare the timer but I do not know where and I am not sure of the syntax.

Thanks,

HarryBedi

I am looking for a way to measure how long it takes to complete a sub routine in VBA. I have code which posts data to matlab and then calls it back. What I need to know is how long does it take to complete each subroutine.

Can anyone help me create a code which will measure this? I need to measure the time taken in 100ths of a second.

Is there any simple code to complete this? I am pasting a sample of my code which is using Matlab as a COM server.

Dim Matlab As Object

Dim MReal(10, 0) As Double

Dim i As Integer

Dim j As Integer

Dim MImag() As Double

Dim value As Double

Dim RealValue As Double

Application.ScreenUpdating = False 'turn off screen updating to increase timing

Sheets("SOURCE").Range("A2:G11").Copy Sheets("Data").Range("A2:G11")

Set Matlab = CreateObject("Matlab.Application") 'invoke matlab

For i = 0 To 10

For j = 0 To 0

' Mreal(i, j) = Worksheets("Data").Range(Cells(i + 1, j + 1), Cells(i + 1, j + 1)).value

MReal(i, j) = Worksheets("Data").Range("B2").Offset(i, j).value

Next j

Next i

Call Matlab.PutFullMatrix("xxxx", "base", MReal, MImag)

Result = Matlab.Execute("Logxxxx = price2ret(xxxx)")

Result = Matlab.Execute("save('C:\Warrior\xxxx.mat', 'xxxx')")

Result = Matlab.Execute("ExpRetxxxx = Mean (Logxxxx)")

End Sub

I am sure I woould need to declare the timer but I do not know where and I am not sure of the syntax.

Thanks,

HarryBedi

## Comment