Hi, I have used time stamp in vb.net like this -
btnGenerateReport.Enabled = False
Dim sw As Stopwatch = Stopwatch.StartNew()
getreport() */ this is my function through ehich i am loading data
sw.Stop()
Dim ts As TimeSpan = sw.Elapsed
Label1.Text = ts.TotalMilliseconds.ToString() + " ms for summary report"
now i am getting time in milliseconds in my label
but each time milliseconds are different means first time it is "3392.2505 ms"
and same code when i run second time it is "3696.0097 ms".
it should be same....
Please tell me is there ant error in my code or why it is different each time???
Thanks
Loading
VulpesPosted Jul 19, 2013, 10:17 AM
Each time the report is generated the average time is recalculated:
rachayita jaiswalPosted Jul 19, 2013, 12:14 AM
VulpesPosted Jul 18, 2013, 8:54 AM
There are a number of reasons for this. For example, the thread on which the code is running may be interrupted by the operating system to run another thread or (in the case of .NET) the CLR may decide to perform a garbage collection in the middle of the operation.
Also, if you're obtaining data from an external server, the time taken for this to arrive will depend amongst other things on how busy the server is at the time of the request.