okamibl / xy-vsfilter

Automatically exported from code.google.com/p/xy-vsfilter
0 stars 0 forks source link

Profiling VSFilter using VS2010 #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
cyberbeing asked me to write up the steps to profile VSFilter using VS2010's 
profiler so here it is. You need to have VS2010 Premium or Ultimate to be able 
to use the profiler.

Steps to create a profiling session:
1. Go to Analyze->Launch Performance Wizard.
2. Choose either CPU Sampling or Instrumentation for profiling type and hit 
next. 
3a. If you chose CPU sampling, in this screen, choose "An executable(.EXE 
file)" and hit next.
3b. If you chose Instrumentation, in this screen, choose "A dynamic 
link-library (.DLL File)" and hit next.
4a. Give the file path to the media player you want to profile with. I just use 
MPC-HC included in CCCP.
4b. Give the file path to the media player and the file path for the 
VSFilter.dll.
5. Hit next to finish.
6. You will now have a .psess file, which you can save and reload so you don't 
have to recreate the profiling session everytime.

Steps to setup VSFilter for profiling:
1. In Configuration Manager for the Solution, create a new configuration called 
Profile and have it duplicate the Release configuration of the solution.
2. Open the VSFilter project properties and create a new configuration called 
"Profile" and make it a duplicate of the "Release Filter" configuration.
3. Set the "Profile" to be the active configuration and go into the Linker 
settings.
4. In the Advanced section, enable the Profile option.
5. In the Configuration Manager, set the active solution configuration to the 
Profile configuration and set VSFilter's configuration to the Profile 
Configuration.

Steps to profile:
1. Build VSFilter in the profile configuration and move it into the directory 
where it's registered.
2. Load the profiling session if it hasn't been loaded already.
3. In the Performance Explorer window (View->Other Windows->Performance 
Explorer), hit the "Start Profiling" button in the top bar.
4. Your chosen media player should now open and you can profile whatever it is 
you want.

Some notes: Profiling starts as soon as the process starts and ends when the 
process exits, and will generate a lot of data, which makes profiling things 
that last more than 30 seconds unreasonable. CPU Sampling gives finer grained 
data and shows what instructions the CPU spent the most time executing or 
stalled on, but you need to inspect the assembly to see the correct 
instructions due to compiler optimizations (the lines VS2010 highlights in the 
code as hot spots will almost certainly not be right, but they'll usually be in 
the general vicinity of the actual instructions). Instrumentation gives you a 
broad view of how long individual functions spent executing, and how many times 
they were called, but you won't be able to see what instructions a function 
spent most of its time on. Finally, if VSFilter or your media player is a 
protected system directory like Program Files, VS2010 needs to be started with 
Administrator privileges.

Profiling tip: Use filters in the Summary window of the analyzed to drill down 
into sections of the profiled data so you can isolate what's happening when 
VSFilter is choking.

Original issue reported on code.google.com by utopiafa...@gmail.com on 6 Nov 2011 at 9:52

GoogleCodeExporter commented 8 years ago

Original comment by cyber.sp...@gmail.com on 7 Nov 2011 at 7:31