Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fine-grained timer for VBScript performance measurements

I'm doing some performance measurements in VBScript. I want to measure how fast my algorithm performs

t1 = Now()  
doAlotOfWork ()  
t2 = Now()  
MsgBox "Operation took " & DateDiff ("s", t1, t2)  & " seconds."

This gives me the time in seconds. If one algorithm results in a 1 second execution time and another in 2 seconds, this will hardly give me any useful information. I need to blow up the problem size to something that takes a minute to execute.

Does anybody know of a way to do these kinds of measurements in VBScript, but then more fine-grained. Something that introduces milliseconds for example.

I have a feeling that there must be a solution in WMI.

like image 348
mgr326639 Avatar asked Mar 08 '11 09:03

mgr326639


2 Answers

You could use the VBScript Timer function to get the elapsed time in milliseconds:

The Timer function returns the number of seconds and milliseconds, since 12:00 AM.

like image 155
stuartd Avatar answered Nov 15 '22 07:11

stuartd


If you are working in HP QuickTest Pro, here are two more methods that you are afforded:

Timers will give a result (in milliseconds) that you can store in a variable

MercuryTimers("timerName").Start
Wait 2
Msgbox "Time is ticking..."
MercuryTimers("timerName").Stop
Msgbox "Elapsed time is: " & MercuryTimers("timerName").Elapsedtime & " milliseconds"

Transaction times show up in the QTP results / report

Services.StartTransaction "transactionName"
Wait 2
Msgbox "Time is ticking..."
Services.EndTransaction "transactionName"
like image 41
Michael Innes Avatar answered Nov 15 '22 09:11

Michael Innes