Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

how to calculate the processing time for some operation..

Hye all,
i want to calculate the proccessing time for 1 function.
for example once user click a button, it will capture the current time until finish time to the some operation.
for example:

Private Sub btnTest_Click(..)
<current start time>
....
....
<current finish time>

time take = <current start time> - <current finish time>

End Sub

thanks~~
[436 byte] By [izza_azhar] at [2007-11-11 8:19:04]
# 1 Re: how to calculate the processing time for some operation..
Dim StartTime As DateTime = DateTime.Now
' Perform operation
Dim EndTime As DateTime = DateTime.Now
Dim Elasped As TimeSpan = EndTime.Subtract(StartTime)
Phil Weber at 2007-11-11 21:47:36 >
# 2 Re: how to calculate the processing time for some operation..
Dim StartTime As DateTime = DateTime.Now
' Perform operation
Dim EndTime As DateTime = DateTime.Now
Dim Elasped As TimeSpan = EndTime.Subtract(StartTime)

ok.. let say i want to put the Elasped to the text box..
i cannot simply code : Me.txtTime.Text = Val(Elasped) because it wasnt string..
can u help me how to do that? the output shud be in in seconds
izza_azhar at 2007-11-11 21:48:39 >
# 3 Re: how to calculate the processing time for some operation..
Type:

txtTime.Text = Elapsed. <- type the period

A list of elements of the TimeSpan structure will appear and you can select the one(s) you want to display. If you want to show hours, minutes and seconds, you may simply use Elapsed.ToString.
Phil Weber at 2007-11-11 21:49:48 >
# 4 Re: how to calculate the processing time for some operation..
Type:

txtTime.Text = Elapsed. <- type the period

A list of elements of the TimeSpan structure will appear and you can select the one(s) you want to display. If you want to show hours, minutes and seconds, you may simply use Elapsed.ToString.

got it.. thanks~
izza_azhar at 2007-11-11 21:50:49 >
# 5 Re: how to calculate the processing time for some operation..
koi assignment mili hai kiya ?
NabeeL at 2007-11-11 21:51:47 >