.netperformanceunit-testingresharper

Unit test performs better when started from ReSharper Test Session?


I have a unit test including a stopwatch measuring the execution time of certain .NET library calls.

I get significantly shorter execution times when I start the unit test from ReSharper Test Session in contrast with starting the exact same test from Visual Studio Test Explorer. By significantly I mean half, execution time when started from ReSharper is half the execution time when started from VS Test Explorer.

My question is → what's causing the difference?

ReSharper:

VS Test Explorer:

Everything is compiled in Release mode The measured code is not implemented in the unit test, the test only invokes the measure functions from a compiled assembly

I created a console application executing the same test → measured execution times are similar to VS Test Explorer.

What does ReSharper Test Session runner do to achieve better performance than a regular .NET console application?


Solution

  • I am the author of the ReSharper test runner and I have no idea. :)

    First of all, our test runner (as well as VS's) covers a multitude of scenarios. Them being different runtimes (.NETFramework | .NETCore | Mono), different target frameworks, different test frameworks. To know where to look I would first need to know your setup.

    But the statement that the calls work faster from our runner than from a plain console app is really bizarre. The only thing that comes to mind right now is that we enable server garbage collection mode by default for .NETFramework.