Best way to time a process in C#

Hi,
I am using NHIbernate to create the database connections. I would like to time how long time certain operations take. I havn't done this before, so therefor I ask you experts; What is the most precise way to time a process in c#?
Thanks
DofsAsked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
You can use the System.Diagnostics.Stopwatch for that

public void YourProcedure() 
{ 
    System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); 
    //do your stuff 
    
    sw.Stop(); 
    messagebox.show(sw.Elapsed.Seconds); 
} 

Open in new window

0
 
DofsAuthor Commented:
Thank you very much, it worked well :)
0
All Courses

From novice to tech pro — start learning today.