Programmatic Access to the Profiler
One of the DLLs that comes with the profiler is HibernatingRhinos.Profiler.Integration, this DLL can give you programmatic access to the profiler object model. For example, you may do so inside your unit tests to be able to assert on the behavior of your code.
var captureProfilerOutput = new CaptureProfilerOutput(@"/path/to/profiler.exe");
captureProfilerOutput.StartListening();// run code that uses Entity Frameowrk
Report report = captureProfilerOutput.StopAndReturnReport();
// Assert / inspect on the report instance
- Create a new CaptureProfilerOuput file and pass it the path to the efprof.exe executable.
- Call StartListening to start the listening to your application's behavior.
- Execute your code
- Call StopAndReturnReport to get the report and assert / inspect it.
You can also use this DLL to give you programmatic access to the XML report files that are generated during the continuous integration build. This is done using the following code:
var xml = new XmlSerializer(typeof (Report));
using(var reader = File.OpenText(reportFile))
{
Report result = (Report)xml.Deserialize(reader);
}