2010-04-20 27 views
2

我試圖從VS單元測試工具運行它時剖析我的.NET DLL,但是我遇到問題。我正在使用獨立的命令行分析器,因爲VS2008 Professional不附帶內置的分析器。在VS2008 Professional中使用MS獨立分析器

我有一個開放的CMD窗口,並運行以下命令(我儀表早前這就是爲什麼vsinstr給了警告,它沒有):

C:\...\BusinessRules\obj\Debug>vsperfclrenv /samplegclife /tracegclife /globalsamplegclife /globaltracegclife 
Enabling VSPerf Sampling Attach Profiling. Allows to 'attaching' to managed applications. 

Current Profiling Environment variables are: 
COR_ENABLE_PROFILING=1 
COR_PROFILER={0a56a683-003a-41a1-a0ac-0f94c4913c48} 
COR_LINE_PROFILING=1 
COR_GC_PROFILING=2 

C:\...\BusinessRules\obj\Debug>vsinstr BusinessRules.dll 
Microsoft (R) VSInstr Post-Link Instrumentation 9.0.30729 x86 
Copyright (C) Microsoft Corp. All rights reserved. 

Error VSP1018 : VSInstr does not support processing binaries that are already instrumented. 

C:\...\BusinessRules\obj\Debug>vsperfcmd /start:trace /output:foo.vsp 
Microsoft (R) VSPerf Command Version 9.0.30729 x86 
Copyright (C) Microsoft Corp. All rights reserved. 

C:\...\BusinessRules\obj\Debug> 

然後我跑了單元測試,行使儀表碼。當單元測試是完全的,我沒有...

C:\...\BusinessRules\obj\Debug>vsperfcmd /shutdown 
Microsoft (R) VSPerf Command Version 9.0.30729 x86 
Copyright (C) Microsoft Corp. All rights reserved. 


Waiting for process 4836 (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\vstesthost.exe) to shutdown... 

這顯然是在等待VS2008封閉,因此我關閉了它......

Shutting down the Profile Monitor 
------------------------------------------------------------ 

C:\...\BusinessRules\obj\Debug> 

所有看起來不錯,有一個3.2MB目錄中的foo.vsp文件。我接下來做了...

C:\...\BusinessRules\obj\Debug>vsperfreport foo.vsp /summary:all 

Microsoft (R) VSPerf Report Generator, Version 9.0.0.0 
Copyright (C) Microsoft Corporation. All rights reserved. 

VSP2340: Environment variables were not properly set during profiling run and managed symbols may not resolve. Please use vsperfclrenv before profiling. 
File opened 
Successfully opened the file. 
A report file, foo_Header.csv, has been generated. 
A report file, foo_MarksSummary.csv, has been generated. 
A report file, foo_ProcessSummary.csv, has been generated. 
A report file, foo_ThreadSummary.csv, has been generated. 
Analysis completed 
A report file, foo_FunctionSummary.csv, has been generated. 
A report file, foo_CallerCalleeSummary.csv, has been generated. 
A report file, foo_CallTreeSummary.csv, has been generated. 
A report file, foo_ModuleSummary.csv, has been generated. 

C:\...\BusinessRules\obj\Debug> 

注意關於環境變量和使用vsperfclrenv的警告?但我已經跑了!也許我使用了錯誤的開關?我不知道。無論如何,加載CSV文件導入Excel或使用perfconsole工具提供有用的信息負載無用的符號名:

*** Loading commands from: C:\temp\PerfConsole\bin\commands\timebytype.dll 
*** Adding command: timebytype 
*** Loading commands from: C:\temp\PerfConsole\bin\commands\partition.dll 
*** Adding command: partition 

Welcome to PerfConsole 1.0 (for bugs please email: [email protected]), for help type: ?, for a quickstart type: ?? 

> load foo.vsp 
*** Couldn't match to either expected sampled or instrumented profile schema, defaulting to sampled 
*** Couldn't match to either expected sampled or instrumented profile schema, defaulting to sampled 
*** Profile loaded from 'foo.vsp' into @foo 

> 
> functions @foo 
>>>>> Function Name 

Exclusive   Inclusive   Function Name Module Name 
-------------------- -------------------- -------------- --------------- 
900,798,600,000.00 % 900,798,600,000.00 % 0x0600003F  20397910 
14,968,500,000.00 % 44,691,540,000.00 % 0x06000040  14736385 
8,101,253,000.00 % 14,836,330,000.00 % 0x06000041  5491345 
3,216,315,000.00 % 6,876,929,000.00 % 0x06000042  3924533 
<snip> 
71,449,430.00 %  71,449,430.00 %  0x0A000074  42572 
52,914,200.00 %  52,914,200.00 %  0x0A000073  0 
14,791.00 %   13,006,010.00 %  0x0A00007B  0 
199,177.00 %   6,082,932.00 %  0x2B000001  5350072 
2,420,116.00 %  2,420,116.00 %  0x0A00008A  0 
836.00 %    451,888.00 %   0x0A000045  0 
9,616.00 %   399,436.00 %   0x0A000039  0 
18,202.00 %   298,223.00 %   0x06000046  1479900 

我如此接近能夠找到瓶頸,如果只有它會給我的功能和模塊名稱而不是十六進制數字!

我在做什麼錯?

--- Alistair。

回答

0

一對夫婦可能的事嘗試(注意我不是在命令行分析器的專家 - 我只用它,而回幾次):

  1. docs for vsperfclrenv說:

    您選擇的選項取決於您使用的三種類型的分析中的哪一種:採樣,檢測或全局。

    你已經得到了你的電話的所有3種類型的分析的選項vsperfclrenv - 我建議你選擇一個類型,開始了,並從那裏是否工作繼續前進,但你想嘗試其他的東西看看他們是否更好地工作。

  2. 您可能還需要指定符號的位置(即使這不是使用vsperfclrenv完成的)。可以使用_NT_SYMBOLS_PATH環境變量或/SymbolPath選項至vsperfreport(或通過將.pdb文件與二進制文件放在同一位置)配置符號位置。詳情請參閱"How to: Specify Symbol File Locations from the Command Line"

2

的原因原來是我沒有運行在該環境變量中定義的相同過程中的可執行文件。這是改動的代碼需要的環境變量,而不是探查器訪問。

因此,我在使用vsperfclrenv後直接從命令行運行了VS2008,並且它都可以正常工作,並且我有我的函數名稱。

不幸的是我仍然得到Schema錯誤,這意味着我無法深入調用樹,但我至少設法找出這個特定的瓶頸。

--- Alistair。