Jun 2 2008

Load tests don't like code coverage

Category: .NetRory Primrose @ 11:13

I have been pulling my hair out this afternoon trying to figure out why my code is performing so badly in a load test. After playing with the code and running a lot of tests, I didn't have any answers until I looked at my testrunconfig file. Code coverage was the first thing I looked at.

With code coverage turned on, the report looked like this.

Load Test With Code Coverage

After I turned code coverage off, I was much happier.

Load Test Without Code Coverage

The Test Response Time graphs (top right) highlight the difference between the test run performance as does the the CPU usage (red line in the bottom right graph). Of the four tests, the one that is doing the most work was averaging 6.76 seconds per test with code coverage which is atrocious. Without code coverage, this test was running an average of 0.00024 seconds per test. Just a little different.

Updated: Changed images so they are more readable and changed the scale of the Test Response Time graph so the difference of the tests can be seen.

Tags:

Comments

1.
Ryan Boucher Ryan Boucher says:

I'm glad you checked code coverage first. Although I do wonder why the default setting is to have it on (not your fault more of a Microsoft thing I would suspect)

Ideally your load testing (or perf/stress testing) configuration should resemble the eventual production configuration. This includes instrumentation (if you only turn it on in prod when needed) and hardware architecture.

2.
Rory Primrose Rory Primrose says:

The default setting is to have it off. We have turned it on so that we can get code coverage of the unit tests.

The side issue here is that the code coverage setting is defined in a testrunconfig file which is stored against the solution, not an individual project. You can have multiple testrunconfig files, but only one can be the active config.

This means that in order to run load tests from the IDE, you either need two testrunconfig files and switch the active one to that which doesn't enable code coverage, or manually edit the only testrunconfig to disable the setting. Manual effort either way. It would have been nice if the testrunconfig could be assigned to a project.

We got around this in team build by running all unit tests, specifying the testrunconfig (which is why one config is easier), and then running the load tests as a separate task that doesn't specify a config.

3.
trackback Rory Primrose says:

Trackback from Rory Primrose

Tracing Performance Tips

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading