PerformanceCounter class has been commonly used to profile a process by getting CPU usage and memory.
However, PerformanceCounter does not work in Linux. I could not change my project from .NET Core to .NET standard or .NET framework
I have checked this post: How to get CPU Usage and Virtual Memory for a process in .Net Core?.
However I could not use Mono in my work.
Some website (https://stackify.com/performance-counters-net-core/) reveals that EventCounter in .NET Core could do the job but another forum https://gitter.im/dotnet/coreclr/archives/2017/02/08 has confirmed that it does not work.
How do I measure CPU usage and memory in .NET Core without using PerformanceCounter?