调用 String.Concat 导致 high-cpu 未显示在 CPU Usage 选项卡中
Call to String.Concat causing high-cpu not showing in CPU Usage tab
我的示例应用程序如下所示。
class Program
{
static List<XmlNode> memList = new List<XmlNode>();
static void Main(string[] args)
{
Console.WriteLine("Press any key to start");
Console.ReadKey();
CauseHighCPU();
}
static public void CauseHighCPU()
{
string str = string.Empty;
for (int i = 0; i < 100000; i++)
{
str += " Hello World";
}
}
}
我预计字符串连接会导致高 cpu。当我使用 PerfView 分析应用程序时,声音非常清晰。
我正在尝试使用 Visual Studio 2017 诊断中心进行类似的分析。以下是其 CPU 使用选项卡显示的内容。
它的调用树视图没有显示任何对 Concat 的调用,尽管这里有一些外部代码
这让我觉得它可能与我的配置中缺少的东西有关。正如您在此处看到的,未选中启用仅我的代码。
也不确定是否相关,但这里是符号设置。
任何可能导致 VS 未显示高cpu 使用率的根本原因的错误。
你不应该查看 Debugging 的选项,而是查看 Performance Tools 的选项,然后禁用 "Just my code":
我的示例应用程序如下所示。
class Program
{
static List<XmlNode> memList = new List<XmlNode>();
static void Main(string[] args)
{
Console.WriteLine("Press any key to start");
Console.ReadKey();
CauseHighCPU();
}
static public void CauseHighCPU()
{
string str = string.Empty;
for (int i = 0; i < 100000; i++)
{
str += " Hello World";
}
}
}
我预计字符串连接会导致高 cpu。当我使用 PerfView 分析应用程序时,声音非常清晰。
我正在尝试使用 Visual Studio 2017 诊断中心进行类似的分析。以下是其 CPU 使用选项卡显示的内容。
它的调用树视图没有显示任何对 Concat 的调用,尽管这里有一些外部代码
这让我觉得它可能与我的配置中缺少的东西有关。正如您在此处看到的,未选中启用仅我的代码。
也不确定是否相关,但这里是符号设置。
任何可能导致 VS 未显示高cpu 使用率的根本原因的错误。
你不应该查看 Debugging 的选项,而是查看 Performance Tools 的选项,然后禁用 "Just my code":