Saturday 29 August 2015

Time taken to execute a script - QTP

''Timer returns number of seconds elapsed since 12am
t1 = Timer
wait 2
t2= Timer
t= t2-t1                   
' Int() behaves exacly like Floor() function, ie. it returns the biggest integer lower than function's argument
temp = Int(t)

Miliseconds = Int((t-temp) * 1000)
Seconds = temp mod 60
temp    = Int(temp/60)
Minutes = temp mod 60
Hours   = Int(temp/60) 

''1 sec= 1000 milliseconds
''1 Min= 60 seconds= 60000 milli seconds
''1 Hour= 60 Mins=360 seconds= 360000 milli sends..



msgbox " Hours, Minutes, Seconds, Miliseconds: " & vbtab& Hours & vbtab& Minutes&   vbtab&Seconds& vbtab& Miliseconds

' Let's format it
strTime =           String(2 - Len(Hours), "0") & Hours & ":"
strTime = strTime & String(2 - Len(Minutes), "0") & Minutes & ":"
strTime = strTime & String(2 - Len(Seconds), "0") & Seconds & "."
strTime = strTime & String(4 - Len(Miliseconds), "0") & Miliseconds

msgbox  strTime

No comments:

Post a Comment