So if i just want to see what JIT compiles while debuggin I can go into Debug -> Windows -> Disassembly
and watch everything I want to. But JIT doesn't generate optimized code when executing under debugger. For example:
private static void Foo()
{
var sw = Stopwatch.StartNew();
for (int i = int.MinValue; i < int.MaxValue; i++) {}
sw.Stop();
Console.WriteLine(sw.Elapsed);
}
this code takes 12 seconds (on my i7-3770) when is running under debugger but only 1 second if isn't.
So it's quite initeresting: if cycle isn't removed from the code - why it runs 10 times faster. And if it's removed (because of code uselessness), why it takes this second, not several ticks?..
What is the question?
How to see final x86 optimized code without using NGen ?