Hi!
I am developing an application in asp.net with c# as the codebehind. I have to determine, how long (time) did it take for a particular piece of code to execute. How to achieve this?
Printable View
Hi!
I am developing an application in asp.net with c# as the codebehind. I have to determine, how long (time) did it take for a particular piece of code to execute. How to achieve this?
Well, not sure if this is what you want
am posting in VB.NET
Code:Private Function DoSomething()
dim dtStartTime as date = now
dim i as integer
For i = 0 to 100000
'Do something here
Next
dim dtEndTime as date = now
'The difference bewteen the end time and start time would tell you how much time it took your code to execute.
ENd Function
Thanks a ton.
I want to make a class of this, so that it can be used anywhere by creating an instance of it and calling its function.
Now, shall I have two properties for starttime and endtime and one function to calculate the difference.
Can you just give me a sample code. I am a newbie as my background was vb/asp..and I have to jump to the .net world.