Hello Friends,
In this post, we'll see how to measure the total time taken by a test/script in execution.
It's easy to get execution time using Timer, but here we will measure the time and convert it to Hr-Min-Sec format. Let's see how-
Dim StartTime, EndTime
StartTime = Timer
'enter your script here
For I = 1 To 5
wait 1
Next
EndTime = Timer
TimeTaken = EndTime - StartTime
msgbox TimeTaken
You have execution time stored in 'TimeTaken' variable but it is in milisecond format
Now, let's convert it to Hr-Min-Sec. It will clearly tell you how many seconds, minutes or hours (if any :) ) have been taken by the script. Following is the function to do the job for us. Just pass the 'TimeTaken' to it and chill :)
Function func_ExecutionTime(TimeTaken)
If TimeTaken>=3600 Then
hr=int(TimeTaken/3600)
rem1=int(TimeTaken mod 3600)
str=hr&" hr "
If rem1>=60 Then
min=int(rem1/60)
sec=int(rem1 mod 60)
str=str&min&" min "&sec&" sec."
else
sec=rem1
str=str&sec&" sec."
End If
Else If TimeTaken>=60 Then
min=int(TimeTaken/60)
sec=int(TimeTaken mod 60)
str=str&min&" min "&sec&" sec."
else
sec=TimeTaken
str=str&sec&" sec."
End If
End If
func_ExecutionTime = str
End Function
How to call this function -
TimeTaken_HMS = func_ExecutionTime(TimeTaken)
msgbox TimeTaken_HMS
If you have multiple actions in your test, you can measure the execution time for every individual action.
Post you comments for any queries/feedback.
In this post, we'll see how to measure the total time taken by a test/script in execution.
It's easy to get execution time using Timer, but here we will measure the time and convert it to Hr-Min-Sec format. Let's see how-
Dim StartTime, EndTime
StartTime = Timer
'enter your script here
For I = 1 To 5
wait 1
Next
EndTime = Timer
TimeTaken = EndTime - StartTime
msgbox TimeTaken
You have execution time stored in 'TimeTaken' variable but it is in milisecond format
Now, let's convert it to Hr-Min-Sec. It will clearly tell you how many seconds, minutes or hours (if any :) ) have been taken by the script. Following is the function to do the job for us. Just pass the 'TimeTaken' to it and chill :)
Function func_ExecutionTime(TimeTaken)
If TimeTaken>=3600 Then
hr=int(TimeTaken/3600)
rem1=int(TimeTaken mod 3600)
str=hr&" hr "
If rem1>=60 Then
min=int(rem1/60)
sec=int(rem1 mod 60)
str=str&min&" min "&sec&" sec."
else
sec=rem1
str=str&sec&" sec."
End If
Else If TimeTaken>=60 Then
min=int(TimeTaken/60)
sec=int(TimeTaken mod 60)
str=str&min&" min "&sec&" sec."
else
sec=TimeTaken
str=str&sec&" sec."
End If
End If
func_ExecutionTime = str
End Function
How to call this function -
TimeTaken_HMS = func_ExecutionTime(TimeTaken)
msgbox TimeTaken_HMS
If you have multiple actions in your test, you can measure the execution time for every individual action.
Post you comments for any queries/feedback.
A very informative article and lots of really honest and forthright comments made! This certainly got me thinking a lot about this issue so thanks a lot for posting!
ReplyDeletefree cell phone
it's really help us............thanks
ReplyDeleteLast line of the function ---> Function func_ExecutionTime(TimeTaken)
ReplyDeleteNeed to be changed from: f_ExecutionTime = str
To: func_ExecutionTime = str
Other than its working so perfect. Thanks for it
Thank you
ReplyDeleteThis is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. ( Locateanumber.com | www.locateanumber.com | http://locateanumber.com | https://locateanumber.com )
ReplyDeleteThis is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. http://locateanumber.com
ReplyDeleteThanks for the blog post buddy! Keep them coming... hemsida
ReplyDelete