Simple way to check your code performance
Hi guys,Of course, we all know foreach loop takes more time than for loop and there are lot of similar scenarios in .Net. Even if it takes lot of time, we'll be forced to use foreach loop at some cases. So it'll be better, if we come to know the time taken for executing a piece of code at the runtime. Here is a simple way to find out the time taken for each process.It just writes the start time and finish time taken for the process in the debug window. Debug.Indent() method simply changes the indentation of the Output by one level and Debug.WriteLine() method writes a string in the debug window.
Here is the snippet
//Increases the current IndentLevel
System.Diagnostics.Debug.Indent();
//Writes the starttime
System.Diagnostics.Debug.WriteLine("DEBUG START TIME -> : " + DateTime.Now.ToString("HH:mm s:fff"));
//Execute the code
ConfigureControls();
//Writes the finish time
System.Diagnostics.Debug.WriteLine("DEBUG FINISH TIME -> : " + DateTime.Now.ToString("HH:mm s:fff"));
//Reduces the current IndentLevel
System.Diagnostics.Debug.Unindent();