admin管理员组

文章数量:1327984

I have a program that launches a child process where the code I want to profile is running.

While I can run the Debug > Performance Profiler > CPU Usage on the parent process, I can't seem to see any of the child process events. Is this possible? Has anyone attempted this before?

Here is an example of how I'm launching the child process from the parent.

    using System.Diagnostics;
    
    namespace Parent
    {
        internal class Program
        {
            static void Main(string[] args)
            {
var proc = Process.Start("\"C:\\Users\\user\\source\\repos\\ProfileChild\\Child\\bin\\Debug\\net8.0\\Child.exe\"");
    
                if (proc != null)
                    proc.WaitForExit();
            }
        }
    }

I have a program that launches a child process where the code I want to profile is running.

While I can run the Debug > Performance Profiler > CPU Usage on the parent process, I can't seem to see any of the child process events. Is this possible? Has anyone attempted this before?

Here is an example of how I'm launching the child process from the parent.

    using System.Diagnostics;
    
    namespace Parent
    {
        internal class Program
        {
            static void Main(string[] args)
            {
var proc = Process.Start("\"C:\\Users\\user\\source\\repos\\ProfileChild\\Child\\bin\\Debug\\net8.0\\Child.exe\"");
    
                if (proc != null)
                    proc.WaitForExit();
            }
        }
    }
Share Improve this question edited Jan 26 at 8:38 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Dec 3, 2024 at 1:04 Russel85Russel85 111 silver badge3 bronze badges 2
  • “Launches a client program” - how? By running a .exe file? – stuartd Commented Dec 3, 2024 at 2:31
  • @stuartd I've added an example that shows how I'm launching the child process. – Russel85 Commented Dec 3, 2024 at 19:28
Add a comment  | 

1 Answer 1

Reset to default 0

To analyze the CPU usage of a child process in Visual Studio, you can try the following:

1: Start the parent process.

2: Open the Debug menu and select Attach to Process.

3: Find and select the child process in the process list and click Attach.

4: Then you can perform performance analysis and the CPU usage of the child process should be recorded.

Related documents you can refer to: Document 1, Document 2

本文标签: cIs it possible to profile a NET child process using Visual Studio39s Profiling ToolsStack Overflow