From my integration test:
// Act
Stopwatch w = new Stopwatch();
w.Start();
userService.Create(userDTO);
w.Stop();
public void Create(UserDTO userDTO)
{
Ngen will cut that in half. Entity Framework is not compiled natively. I have a script that compiles everything in the output directory. Makes a big difference even when debugging.
@ECHO OFF
REM *********************************************************************************************************
REM Compiles project's .net assemblies to native images to improve startup time and overall performance
REM ---------------------------------------------------------------------------------------------------------
REM Author: Brian Freeman
REM History:
REM 12/2/2013 Created
REM *********************************************************************************************************
REM Scenarios:
REM /Debug - Generate images that can be used under a debugger
REM /Profile - Generate images that can be used under a profiler
REM /NoDependencies - Generate the minimal number of native images
REM required by this scenario
REM Options
REM /verbose
SET DEFAULTOPTIONS= /Debug /Verbose
@ECHO. -------------------------------------
@ECHO. Native Image Generator (Ngen.exe)
@ECHO. -------------------------------------
@ECHO Current Defaults are %DEFAULTOPTIONS%
REM ---------------------------------------------------------------------
REM Small chance these might not be the locations of the .net framework
REM Needs to be added to as the framework gets new versions
REM ---------------------------------------------------------------------
SET ngenx86=C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe
SET ngenx64=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe
REM Run from the current Directory to ensure any dependencies are available
pushd ..\DatabaseHelper\Bin\Debug
REM SKIP vshost.exe
ATTRIB +S ..\*.vshost.exe /s
@ECHO. -------------------------------------
@ECHO. Generator x64 Images
@ECHO. -------------------------------------
for /f "delims=" %%f in ('dir *.dll /b /s /a-d-h-s') do %ngenx64% install "%%f" %* %DEFAULTOPTIONS%
for /f "delims=" %%f in ('dir *.exe /b /s /a-d-h-s') do %ngenx64% install "%%f" %* %DEFAULTOPTIONS%
@ECHO. -------------------------------------
@ECHO. Generator x86 Images
@ECHO. -------------------------------------
for /f "delims=" %%f in ('dir *.dll /b /s /a-d-h-s') do %ngenx86% install "%%f" %* %DEFAULTOPTIONS%
for /f "delims=" %%f in ('dir *.exe /b /s /a-d-h-s') do %ngenx86% install "%%f" %* %DEFAULTOPTIONS%
@ECHO OFF
ATTRIB -S ..\*.vshost.exe /s
popd
@ECHO. ---------------------
@ECHO. FINISHED
@ECHO. ---------------------