I want to profile the CPU usage of a class library project which is compiled into a dll with VS2012.
When I go into Analyze -> Launch Performance Wizard, I can choose which project to profile but it only lets me profile executables, so I can't profile my library.
If I profile both of my projects (one is a very simple Form which runs functions from my library and shows some output) then System.Windows.Forms.Application.Run
takes up 97% of my samples - I don't really care about the performance cost of the form, and it overwhelms everything else.
How can I see the performance data for just my dll?
This means that each platform can only use class libraries that are targeted to the same profile so they would appear to require separate class library projects for each platform. There are three major approaches to code sharing that address this problem: .NET Standard projects, Shared Asset Projects, and Portable Class Library (PCL) projects.
Class Profile is another tool to provide a snapshot of the class strengths, stretches, class-wide goals, as well as individual needs.
Adding a Portable Class Library to your solution is very similar to adding a regular Library project. In the New Project dialog select the Multiplatform > Library > Portable Library option: When a PCL is created in Visual Studio for Mac it is automatically configured with a Profile that works for Xamarin.iOS and Xamarin.Android.
Class libraries are the shared library concept for .NET. They enable you to componentize useful functionality into modules that can be used by multiple applications. They can also be used as a means of loading functionality that is not needed or not known at application startup. Class libraries are described using the .NET Assembly file format.
You need to create a unit test which exercises the various library functions you are interested in profiling.
You can then right click on the test in the "Test Explorer" and then select "Profile Test".
This should kick off a performance analysis session for the selected test. I not sure why they hid this very useful feature so well!
In VS2012, this option may be grayed out. In this case you can enable it by deleting your %localappdata%\Microsoft\VisualStudio\11.0\ComponentModelCache
folder and restarting Visual Studio. (source)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With