среда, 11 февраля 2015 г.

Increase NUnit performance on AppVeyor

I think you're familiar with AppVeyor - continuous integration cloud system, which allows to make your builds and run unit-tests on windows-based VM. It's free for open-source projects and very useful when you need to be sure that your program will be compilable and runnable against Windows platform (for Linux there is Travis.CI or docker.io, for OS X you can use Travis.CI again).

When I converted MSTest to NUnit for Microsoft Bond project I have found that nunit tests run 4x-5x times slower than similar MS Tests on appveyor. That was strange because my measurements show that slowness was directly inside the tested methods, not in the nunit framework itself. I started to investigate the issue and found that there is NUnitLite nuget package which do the same things as nunit-console but much faster. What was bad that before using NUnitLite you have to create new console project and reference NUnitLite nuget package. That is not always possible if you don't want to add to your sources some unrelated to your project staff.

So at first I made an AppVeyor script which builds NUnitLite

install_script:
   - nuget install NUnitLite -version 3.0.0-alpha-5 -pre
   - mkdir nunit
   - copy NUnitLite.3.0.0-alpha-5\lib\net45\nunitlite.dll nunit 
   - copy NUnit.3.0.0-alpha-5\lib\net45\nunit.framework.dll nunit
   - csc /platform:anycpu32bitpreferred /out:nunit\nulite.exe /optimize+ NUnitLite.3.0.0-alpha-5\content\Program.cs /r:nunit\nunitlite.dll /r:nunit\nunit.framework.dll

To test with NUnitLite, you can use two ways.

test_script:
   #use this way if you installed NUnitLite version greater than 3.0.0-alpha-5
   - nunit\nulite.exe path\to\your\tests\TestAssembly.dll
   #use this way if you installed NUnitLite version 3.0.0-alpha-5 or lower
   - copy nunit\* path\to\your\tests
   - path\to\your\tests\nulite.exe TestAssembly

Please note that in the second case we start nulite.exe in the folder where your tests are located and pass an assembly name (without extension) as nulite.exe argument

What was interested that without /platform:anycpu32bitpreferred argument nulite.exe works slow on AppVeyor. This argument says to execute generated exe file in x86 mode on the systems which support 32bit. I tried to run nunit-console in x86 mode and this increased speed a lot! To do it just specify --x86 argument for nunit-console version 3.0 or run nunit-console-x86 for nunit 2.6.3 (which is preinstalled by default on AppVeyor)

Комментариев нет:

Отправить комментарий