我怎么能看到我在PerfView昂贵的方法 [英] How can I see me expensive methods in PerfView
问题描述
我创建了一个简单的控制台应用程序,并通过运行命令从PerfView执行它 - > PerfMonTest.exe
我得到的日志文件,并看到应用程序的过程。它是昂贵的预期(99%CPU),但我想深入到昂贵的方法,他们不是在昂贵的方法列表中显示。
有什么我可以做,使它们可见?
下面是当我选择过程中的视图。我希望CallExpensive和CallCheap列表:
选择的主要方法犯规给我蔡斯进一步钻入调用的方法
下面是应用程序:
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用System.Text;
命名空间PerfMonTest
{
类节目
{
静态无效的主要(字串[] args)
{
的for(int i = 0; I< = 2000;我++)
{
CallExpensive(1000);
CallCheap(1000);
CallCheap(400);
}
}
公共静态无效CallExpensive(INT费用)
{
的for(int i = 0; I< =支出;我++)
{
日期时间checkTime = DateTime.Now;
串VAL =10+ i.ToString();
}
}
公共静态无效CallCheap(INT费用)
{
的for(int i = 0; I< =支出;我++)
{
INT J = 2;
}
}
}
}
从它的样子,你没有加载符号的截图。如果你这样做,你会看到,大部分的时间都花在 DateTime.Now
。
如果您在点击主
中的按名称的观点,你会去的呼叫者的观点,它会告诉你哪些方法叫做主
。如果你想钻到什么方法主
在呼唤,你需要去到的被调用者的看法。如果你这样做,你会看到什么主
召唤突破。
然而,在这种特殊情况下的逻辑 CallExpensive
和 CallCheap
就是这么简单,该方法将内联(在释放模式)。由于该方法是内联的,它们不会出现从主
为code已被折叠成主<的呼吁的一部分, / code>本身。
您可以通过将一个调试器验证方法是内联的方法都运行后,并期待在方法描述符的类型。下面是我得到的输出:
0:004> dumpmt -MD 004737c0 EEClass:00471278 模块:00472e94 名称:ConsoleApplication1.Program mdToken:02000002 文件:C:\ TEMP \ ConsoleApplication1 \ ConsoleApplication1 \ BIN \发布\ ConsoleApplication1.exe BaseSize:位于0xC ComponentSize:为0x0 插槽虚函数表:8 在IFaceMap IFaces数:0 -------------------------------------- 方法描述表 进入MethodDe JIT名称 72064a00 71d66728 preJIT System.Object.ToString() 72058830 71d66730 preJIT System.Object.Equals(System.Object的) 72058400 71d66750 preJIT System.Object.GetHash code() 72051790 71d66764 preJIT System.Object.Finalize() 0047c01d 004737b8无ConsoleApplication1.Program..ctor() 004d0050 00473794 JIT ConsoleApplication1.Program.Main(System.String []) 0047c015 004737a0无ConsoleApplication1.Program.CallExpensive(Int32)已 0047c019 004737ac无ConsoleApplication1.Program.CallCheap(Int32)已
事实上, CallExpensive
和 CallCheap
有 NONE
在JIT列中列出表明他们内联(或不调用,但这不是这里的情况)。
I have created a simple console app and execute it from PerfView via Run Command -> PerfMonTest.exe
I get the log file and see the process of the app. It is expensive as expected (99% CPU ), but when I want to drill down into the expensive methods they are not shown in the list of expensive methods.
Is there something I can do to make them visible?
Here is the view when I selected the process. I would expect CallExpensive and CallCheap in the list:
Selecting the Main Methods doesnt give me the chace to drill further into the called methods
Here is the app:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PerfMonTest
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i <= 2000; i++)
{
CallExpensive(1000);
CallCheap(1000);
CallCheap(400);
}
}
public static void CallExpensive(int expense)
{
for (int i = 0; i <= expense; i++)
{
DateTime checkTime = DateTime.Now;
string val = "10" + i.ToString();
}
}
public static void CallCheap(int expense)
{
for (int i = 0; i <= expense; i++)
{
int j = 2;
}
}
}
}
From the screenshots it looks like, you didn't load symbols. If you do, you'll see that most of the time is spent in DateTime.Now
.
If you click on Main
in the By Name view, you'll go to the Callers view, which will tell you which methods called Main
. If you want to drill into what methods Main
is calling, you need to go to the Callees view. If you do that, you'll see the break down of what Main
calls.
However, in this particular case the logic of CallExpensive
and CallCheap
is so simple, that the methods will be inlined (in release mode). Because the methods are inlined, they don't appear as part of the calls made from Main
as the code has been folded into Main
itself.
You can verify that the methods are inlined by attaching a debugger after the methods have run and look at the method descriptors for the type. Here's the output I got:
0:004> !dumpmt -md 004737c0 EEClass: 00471278 Module: 00472e94 Name: ConsoleApplication1.Program mdToken: 02000002 File: C:\temp\ConsoleApplication1\ConsoleApplication1\bin\Release\ConsoleApplication1.exe BaseSize: 0xc ComponentSize: 0x0 Slots in VTable: 8 Number of IFaces in IFaceMap: 0 -------------------------------------- MethodDesc Table Entry MethodDe JIT Name 72064a00 71d66728 PreJIT System.Object.ToString() 72058830 71d66730 PreJIT System.Object.Equals(System.Object) 72058400 71d66750 PreJIT System.Object.GetHashCode() 72051790 71d66764 PreJIT System.Object.Finalize() 0047c01d 004737b8 NONE ConsoleApplication1.Program..ctor() 004d0050 00473794 JIT ConsoleApplication1.Program.Main(System.String[]) 0047c015 004737a0 NONE ConsoleApplication1.Program.CallExpensive(Int32) 0047c019 004737ac NONE ConsoleApplication1.Program.CallCheap(Int32)
The fact that CallExpensive
and CallCheap
have NONE
listed in the JIT column indicates that they were inlined (or not called at all, but that's not the case here).
这篇关于我怎么能看到我在PerfView昂贵的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!