2017-09-14 142 views
1

我的示例應用程序如下所示。調用String.Concat導致高CPU不顯示在CPU使用率選項卡

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來分析應用程序時,這非常響亮而清晰。

enter image description here

我試圖使用Visual Studio 2017年診斷中心做類似的分析。以下是其CPU使用率選項卡顯示的內容。

enter image description here

其呼叫樹視圖中沒有顯示到的毗連任何呼叫,儘管有此 ​​

一些外部代碼這讓我覺得,它可能在我CONFIGRATION缺少相關的東西。正如你在這裏看到的,啓用只是我的代碼是未選中的。

enter image description here

而且不知道其相關的,但這裏是符號的設置。

enter image description here

任何thouhts可能是錯誤,是造成VS沒有顯示高CPU使用率的根本原因。

回答

2

你不應該看在調試的選項,但在性能工具的選項,然後禁用「只是我的代碼」:

Options: disable "Just my code" in Performance tools

+0

這是它我的朋友。非常感謝。但是,這現在會從ntdll.dll wow64.dll中引發太多「垃圾」。 PerfView視圖太乾淨了。無論如何,在VS中有相同類型的堆棧嗎? –

+0

@jimcrown:對不起,我不知道在Visual Studio –

+0

中清理的方法,我會在這裏發佈一個單獨的問題,因爲這是一個單獨的主題 –