你可以使用外部工具,例如https://www.red-gate.com/products/dotnet-development/ants-performance-profiler/或https://www.jetbrains.com/profiler/。这些工具可以让你在运行代码时使用性能分析器,轻松地显示出你的内存和耗时都花费在哪里(它们也提供免费试用版)。