c# – How much time does it take to execute the methods without debugging each line?


Is it possible to see in Visual Studio or other utilies or programms how much time the following methods have been executed? This is a simplified version, but I have a lot of lines of code and it becomes hard to see how much time it took to execute method by method:

Foo foo = new ();
foo.Method_1(); // it takes 1 second to be executed
foo.Method_2(); // it takes 2 second to be executed
foo.Method_3(); // it takes 3 second to be executed

and its implementation:

public class Foo
{
    public void Method_1()
    {
        Thread.Sleep(1000);
    }
    
    public void Method_2()
    {
        Thread.Sleep(2000);
    }
    
    public void Method_1()
    {
        Thread.Sleep(3000);
    }
}

Yeah, I know that it is possible while debugging the following features:

image description

But I want to execute a lot of code and I would like to see a list of methods which shows how much time it takes to execute code without debugging every piece of code. Is there any some tools in Visual Studio or maybe is alternative tools?

Leave a Reply

Your email address will not be published. Required fields are marked *