我尝试了以下方法:
mono --profile=log myprog.exe
收集分析器数据。然后解释一下我调用的内容:
> mprof-report output.mlpd
Mono log profiler data
Profiler version: 2.0
Data version: 14
Arguments: log
Architecture: x86-64
Operating system: linux
Mean timer overhead: 51 nanoseconds
Program startup: Fri Jul 20 00:11:12 2018
Program ID: 19840
Server listening on: 59374
JIT summary
Compiled methods: 8349
Generated code size: 2621631
JIT helpers: 0
JIT helpers code size: 0
GC summary
GC resizes: 0
Max heap size: 0
Object moves: 0
Metadata summary
Loaded images: 16
Loaded assemblies: 16
Exception summary
Throws: 0
Thread summary
Thread: 0x7fb49c50a700, name: ""
Thread: 0x7fb49d27b700, name: "Threadpool worker"
Thread: 0x7fb49d07a700, name: "Threadpool worker"
Thread: 0x7fb49ce79700, name: "Threadpool worker"
Thread: 0x7fb49cc78700, name: "Threadpool worker"
Thread: 0x7fb49d6b9700, name: ""
Thread: 0x7fb4bbff1700, name: "Finalizer"
Thread: 0x7fb4bfe3f740, name: "Main"
Domain summary
Domain: (nil), friendly name: "myprog.exe"
Domain: 0x1d037f0, friendly name: "(null)"
Context summary
Context: (nil), domain: (nil)
但是,没有关于经常调用哪些方法且花费很长时间才能完成的信息,这是我对性能分析的唯一期望。
如何使用Mono分析来收集和输出有关方法调用的总运行时间的信息?像hprof
和cpu=times
这样会生成。
答案 0 :(得分:2)
Mono文档“略有”错误,因为默认情况下未跟踪方法calls
。此选项将创建大量的配置文件日志输出,并极大地减慢“总”执行时间,并且与alloc
之类的其他选项结合使用时,会影响方法的执行时间,从而影响所收集的任何计时。
我个人建议使用calls
分析,将calldepth
调整到对您的分析重要的水平。也就是说,您是否需要分析框架调用?较小的调用深度也可以大大减少所生成日志的大小。
示例:
mono --profile=log:calls,calldepth=10 Console_Ling.exe
产生:
Method call summary
Total(ms) Self(ms) Calls Method name
53358 0 1 (wrapper runtime-invoke) <Module>:runtime_invoke_void_object (object,intptr,intptr,intptr)
53358 2 1 Console_Ling.MainClass:Main (string[])
53340 2 1 Console_Ling.MainClass:Stuff ()
53337 0 3 System.Linq.Enumerable:ToList<int> (System.Collections.Generic.IEnumerable`1<int>)
53194 13347 1 System.Linq.Enumerable/WhereListIterator`1<int>:ToList ()
33110 13181 20000000 Console_Ling.MainClass/<>c__DisplayClass0_0:<Stuff>b__0 (int)
19928 13243 20000000 System.Collections.Generic.List`1<int>:Contains (int)
6685 6685 20000000 System.Collections.Generic.GenericEqualityComparer`1<int>:Equals (int,int)
~~~~
回复:http://www.mono-project.com/docs/debug+profile/profile/profiler/#profiler-option-documentation