| || |
User Gary R. Pynn (email@example.com) posted:
Strange question, but would someone please explain the most efficient way
to calculate elapsed time. I need to time the AUT from start to finish,
calculate the elapsed time and print to file.
Gary R. Pynn, Senior QA-Analyst
Whitehill Technologies - Business Information Transformed and Delivered
Re: Elapsed Time
User DAVID MARSH (DAVID.MARSH@thales-cs.com.nospam) posted:
Way I would do is.
Write a function to write the current time to a text file.
Write a function to read a time value from a text file
Write a function to work out the difference between 2 times.
Write a start function, this writes the start time to the file using the
first function, also use it to know the name and path of the file you stored
the time in.
Write an end function to use function 2 to retreive the original time and
function 3 to work out the length then write it back to the file.
Some people might not bother with the files, but script crashes happen so
often and this would stop the info getting lost, also if many scripts were
being run overnight you could get the times for them all.
If you want all the times in one file I suggest a format like
And append the times, when reading use EOF to find the last one.
Now you have a nice little time library.
Re: Elapsed Time
User Marcus Neto (firstname.lastname@example.org) posted:
This has been covered extensively. Do a quick check in the archives for the
code I provided last week or so as an example. If you cannot find it then
jot me a quick email offline and I will hook you up.
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx
Re: Elapsed Time
User Steve D (SDRYJA@usa.com.nospam) posted:
Try the code below, it gives you the number of seconds it took for the
script to complete:
At the start of your script :
StartHours = hour(now)
StartMinutes = minute(now)
StartSeconds = second(now)
At the End of the script:
TempHours = hour(now)
TempMinutes = minute(now)
TempSeconds = second(now)
'Subtract the TempHours from StartHours and TempMinutes from StartMinutes
'If the script ran past midnight then subtract the TempHours from the
'else subtract normally, same with the minutes.
If Cint(TempHours) < Cint(StartHours) Then
TotalHours = (Cint(TempHours) + 24) - Cint(StartHours)
TotalHours = Cint(TempHours) - Cint(StartHours)
If Cint(TempMinutes) < Cint(StartMinutes) Then
TotalMinutes = (Cint(TempMinutes) + 60) - Cint(StartMinutes)
If TotalHours = 1 Then TotalHours = 0
TotalMinutes = Cint(TempMinutes) - Cint(StartMinutes)
If Cint(TempSeconds) < Cint(StartSeconds) Then
TotalSeconds = (Cint(TempSeconds) + 60) - Cint(StartSeconds)
If TotalMinutes = 1 Then TotalMinutes = 0
TotalSeconds = Cint(TempSeconds) - Cint(StartSeconds)
'If the TotalHours is less than 10 then pad the value with a "0"
If TotalHours < 10 Then
TotalHours = "0" & CStr(TotalHours)
'TotalHours = Cint(TotalHours)
'If the TotalMinutes is less than 10 then pad the value with a "0"
If TotalMinutes < 10 Then
TotalMinutes = "0" & CStr(TotalMinutes)
'TotalMinutes = Cint(TotalMinutes)
If TotalSeconds < 10 Then
TotalSeconds = "0" & CStr(TotalSeconds)
TotalSeconds = Cint(TotalSeconds)
TempSeconds = (TotalHours * 3600) + (TotalMinutes * 60) + TotalSeconds
"Marcus Neto" <email@example.com> wrote in message