Mikal Schacht Jensen Mikal Schacht Jensen - 20 days ago 6
C# Question

Visual studio performance profiling optimization

I have a rather large solution revolving around a WebAPI project. I ran into some performance issues on a particular web service, and used the built-in performance profiler in VS2013 to find the bottlenecks and deal with them. Eventually I got the response time on a HTTP request down from around 500ms to 50ms (I use an external app to perform repeated requests and log the round-trip time).

However, I only see this improvement while running the WebAPI from the performance profiler tool. As soon as I switch back to running it straight from Visual Studio (F5) or on our test server, the response times increase to around 400ms, still an improvement on the original 500, but not exactly magnificent.

It only makes a slight difference if I run it in debug mode or release mode. Setting "debug info" to "none" rather than the default "pdb-only", on all the involved projects helps a tiny bit, bringing the average response time down to around 350ms.

I can't for the life of me, figure out what the performance profiler tool does to optimize the code further. And it's killing me that I've seen how fast it can run, but I'm unable to achieve the same performance.

Answer

Turns out the performance profiler wasn't doing anything different to optimize the code. But it did run IIS Express without any debuggers enabled.

By going to the Web API project's properties, and switching to the Web-tab, I could uncheck all the debuggers, and now the response times during debugging matched what I was seeing when running the profiler. Obviously disabling the ASP.NET debugger, prevents any debugging of the code.

Comments