How to calculate time to execute macro image pro plus

Hi YuriG

How to calculate time to execute macro image pro plus  

Thank You  

Answers

  • edited July 2015
    You can use GetTickCount, which should be declared as:

    ' Declare the Windows call to retrieve the time in milliseconds
    Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

    then you call this function before and after the macro and calculate the difference, which will give you the macro execution time in milliseconds.
     
    Example:

    ' Declare the Windows call to retrieve the time in milliseconds
    Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    
    Sub Test
    	Dim t1 As Long, t2 As Long
    	t1=GetTickCount
    	'Call MyMacro
    	t2=GetTickCount
    	Debug.Print "Time = " & (t2-t1)
    End Sub
    



    Yuri

  • Another method using functions already in the code is as follows:

    Sub TimeTest()
    Dim startTime As Date
    Dim endTime As Date
    Dim diffTime As Date
    ' Wait some duration
    startTime = Time ' Record starting time
    Wait(5) ' Your processing here...
    endTime = Time ' Record end time
    ' Find the difference between the two
    diffTime = endTime - startTime
    ' In "Date" variables the whole value gives the date, while the fraction
    ' is the time of day. Here the difference is scaled by 24 hours,
    ' 60 minutes, and 60 seconds to obtain the difference in seconds.
    Debug.Print CDbl(diffTime) * 24*60*60; " seconds."
    End Sub

    The output from this on my machine is:

     5.0939999999974 seconds.

  • edited July 2015
    Thank you very much, your answers are quick and useful.

    you are very friendly.

    Best regards ...

    Carlos
Sign In or Register to comment.