I have read and practiced the MSDN’s Profiler Tutorial. But I couldn’t find a way to profile a library solution (the button ‘Launch with profiling’ is disabled for libraries).
- The only solution I could think of so far is to create an executable project just for profiling purposes.
- I have already written unit tests for my library, using Visual Studio Team System’s Test Framework, so I imagine I could use them for profile, as Rick Minerich does with NUnit.
Anyone can point me the right direction?
It is possible to profile using your tests. You simply run the profiler on whatever is launching the tests and specify your to-be-profiled assemblies as the profiler targets. However, without knowing exactly what infrastructure you are using for both testing and profiling, it’s pretty much impossible to point you towards a solution.
Because I use NUnit, I’ll use it as an example. You could create a test category and call it profile tests. Then you could run nunit.exe from the profiler with the /include command line option to specify those tests:
You can use the Analyize->Performance Wizard to do this. The dll path would be your assembly and the Executable path would be the nunit-console command line as mentioned above.
I also know that ReSharper adds extensions to Visual Studio to do this for you. With it you can just right click on a test and select ‘Profile TESTNAME’. While it does cost money, I think that there is an evaluation version you could check out.
Also, just as a note, be sure to profile with Release libraries. Release and Debug often have MUCH different performance profiles.