|
NAMEmono-profilers - Mono's bundled profiler modulesSYNOPSISmono --profile=log[:option,...] program.exe [args]...mono --profile=coverage[:option,...] program.exe [args]... mono --profile=aot[:option,...] program.exe [args]... DESCRIPTIONMono ships with a few profiler modules that enable most typical profiling scenarios. This page describes each of them in the sections below.LOG PROFILERThe log profiler is Mono's general-purpose performance profiler. It can collect a wide variety of data that can be analyzed by tools such as mprof-report(1) or the Xamarin Profiler.By default, the log profiler writes its output to output.mlpd. Refer to the mono/profiler/log.h file in the Mono source tree for documentation on the log profiler's file format. A default invocation of the log profiler gathers only basic data: Metadata load and unload events, thread start and stop events, performance counter samples, exception throws, etc. Most users will want to enable some of the heavier features such as GC allocation recording, statistical sampling, heap snapshotting (heapshots), or method entry and exit instrumentation. See the Options sub-section. Note that, in most realistic scenarios, the log profiler will record a vast amount of data. This can lead to very large log files. (The zip and report options can help deal with this.) OptionsThe log profiler supports the following options:
Command serverThe log profiler features a simple command server that currently is only used to trigger manual heapshots (typcally when using the on-demand mode, but also usable with the other modes). A random port will be used to listen for connections unless the port option is used. To trigger a heapshot, open a TCP connection to the command server and send the C string "heapshot\n".The command server supports multiple simultaneous connections. Managed libraryThe log profiler comes with a managed library called Mono.Profiler.Log. This library allows easily reading log files in managed code (e.g., C#) as well as interacting with the profiler at run-time.With the ability to easily read log files, users can write all sorts of interesting analyses that might not be provided by the standard tools (e.g., mprof-report(1)). The LogProfiler class allows users to reconfigure profiler settings at run-time. For example, certain event types can be toggled on or off, the mode and frequency of heapshots and sampling can be changed, etc. Heapshots can also be triggered manually. To use this library, simply pass -r:Mono.Profiler.Log when compiling your code. ExampleCollect GC allocation and sampling data for a program, then generate a report:mono --profile=log:alloc,sample program.exe mprof-report output.mlpd Perform a heapshot on every 5th collection and generate a report directly: mono --profile=log:heapshot=5gc,report program.exe COVERAGE PROFILERThe code coverage profiler collects information about how often code paths are executed. This is done by instrumenting JIT-compiled code at all sequence points. On program exit, the coverage profiler collects all execution count information and outputs it to an XML file. The main use case for the coverage profiler is unit testing: By running unit test suites with the coverage profiler, it is possible to determine whether the unit tests actually cover all the code that they should.By default, the coverage profiler writes its output to coverage.xml. Refer to the mono/profiler/coverage.c file in the Mono source tree for documentation on the schema. Please note that the coverage profiler currently does not support instrumenting AOT-compiled code. When collecting coverage data, one may wish to run Mono with the -O=-aot option to disable loading AOT-compiled code. OptionsThe coverage profiler supports the following options:
Filter filesFilter files can be used to pick and choose which types should be considered for coverage instrumentation. A filter file consists of a series of lines of the form:+|-[image_name]type_name_prefix Here, image_name is something like mscorlib. type_name_prefix can be something like System.Int32 for a specific type or System.App to pick all types starting with App in the System namespace. Lines starting with + indicate that a type should be instrumented for coverage, whereas lines starting with - indicate the opposite. Lines starting with + always override lines starting with - regardless of the order they appear in. Lines not starting with either character are ignored. This can be used to write comments. For example, this is a valid file: # Ignore coverage in network-related code, except HTTP client code. -[MyProgram]MyProgram.Net +[MyProgram]MyProgram.Net.Http.HttpClient ExampleCoverage data for a program can be collected like this:mono -O=-aot --profile=coverage:output=cov.xml program.exe cov.xml will now contain the coverage data. AOT PROFILERThe AOT profiler will record which generic instantiations a program makes use of and save the information to a specified file. This data can then be used by the AOT compiler to compile those generic instantiations ahead of time to reduce program startup time.By default, the AOT profiler writes its output to output.aotprofile. Refer to the mono/profiler/aot.h file in the Mono source tree for documentation on the AOT profiler's file format. OptionsThe AOT profiler supports the following options:
ExampleA profile can be collected and used like this:mono --profile=aot:output=program.aotprofile program.exe mono --aot=profile=program.aotprofile program.exe mono program.exe SEE ALSOmono(1), mprof-report(1) Visit the GSP FreeBSD Man Page Interface. |