Using Enterprise Library Tracer in your main methods will help to check the time taken by each method call. We can easily identify the method which is taking more time and do a Performance fix. This will log the elapsed time on each method.
In the project add reference to “Microsoft.Practices.EnterpriseLibrary.Logging”
Add the using statement
In each method use the tracer as shown.
private void MyMethod()
using (new EntLog.Tracer(“Entering the MyMethod”))
//Your code for MyMethod goes here
Add Config file Settings.
- If you are using windows/Console appliation add a App.Config file. If you are using the Web application use the web.config file.
- Open the .config file using Microsoft Enterprise Library configuration tool.
- R.click the File and add the new Logging Application Block as shown
- Now the Logging details and Enterprise Library dll details are added in the Config file.
Check the Tracing:
- After the code run, the logging details is get stored in the windows eventlog.
- From this we can conclude the above method takes 8.941 seconds to execute.Based on the above you can do the performance fix.
Note: You can disable the Logging by changing the attribute tracingEnabled=”false”