Visual Studio Profiler output

二次信任 提交于 2020-01-23 09:45:09

问题


I wrote a small class that executes Main(), which in turn executes A(). I expected the Main() method to be on its own at the root of the stack call, because it's the topmost function in my application. Everything that's done, should be executed by Main(). I wrote the following code to test that:

namespace ProfilerTest
{
    class Program
    {
        static int _a;

        static void Main()
        {
            while (true)
            {
                A();
            }
        }

        static void A()
        {
            _a += 1;
        }
    }
}

The output of the Profiler Call Tree, however, shows that A() isn't only executed through Main(), it's also executed at the same level as the main function.

What I expected (notice I removed the last line from the call tree):

ProfilerTest.exe              10.333
  ProfilerTest.Program.Main   10.333
    ProfilerTest.Program.A    5.897

Why is this? Is what I'm expecting incorrect? Or do I misinterpret the profiler results?

来源:https://stackoverflow.com/questions/29627551/visual-studio-profiler-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!