Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngen and profiling

I'm trying to use NGen to see if native images of my application run better than the .NET ones. However, I'm having a little bit of trouble figuring out what to do.

My application is called MyApp.exe and it has several dependency DLLs.

I opened up the VS 2010 Command Prompt and ran:

ngen install MyApp.exe /Profile

The command output did not suggest any issues had been encountered.

I then went to C:\Windows\assembly to try and run the EXE but I couldn't find it there (I'm on Windows 7). A little bit of digging told me to use the command prompt to browse into C:\Windows\assembly\NativeImages_v4.0.30319_32. I was eventually ably to locate my MyApp.ni.exe there but of course couldn't open the containing folder in explorer.

I tried to run the program and it told me:

"C:\Windows\assembly\NativeImages_v4.0.30319_32...\MyApp.ni.exe is not a valid Win32 application."

The command output said Access is denied.

I had two questions:

  1. How can I run this program so that I can execute the native version.
  2. How would I go about profiling it? Looks like I won't be able to locate that folder from within the VS2010 profiler because it cannot be seen in explorer.

Thanks.

like image 229
sohum Avatar asked Jun 24 '11 18:06

sohum


1 Answers

Looks like I should have read a little more. Seems like I can just execute the EXE that was passed to NGEN and it should automatically load the native stuff from the cache.

One other issue is that I had to run ngen with both the /profile and /debug flags to make sure I could do both.

This is a nice tutorial on the issue:

http://blogs.msdn.com/b/clrcodegeneration/archive/2010/04/27/ngen-getting-started-with-ngen-in-visual-studio.aspx

like image 53
sohum Avatar answered Sep 27 '22 23:09

sohum