Reputation: 30175
As .net matures, the JIT capabilities have been improved to be brilliantly lazy. That is, don't produce machine code if it isn't needed. In general, this is a good thing.
However, if I am trying to warmup an application I may prefer an aggressive JIT stance. Is there a way to configure a .net application so that all methods of a class are JIT compiled, simply because -the class was constructed?
If yes, my favorite object-creational pattern could instantiate my appliation's object-graph, and I would have everything JIT-ready simultaneously. That would be nice.
Can this be done?
Upvotes: 6
Views: 262
Reputation: 20939
As a side note - you could use NGen.exe to produce native image of your dll's at deployment time (NB:It's not a perfect solution - as it has some drawbacks - check out the documentation carefully)
Upvotes: 2
Reputation: 52679
you mean, you want everything ahead-of-time compiled :-)
They finally did this for you - announced at Build 2014:
Somasegar told me that developers told Microsoft that .NET was always a very productive language to program in, but it didn’t always deliver the performance they were looking for. “We’ve been working on a lot of innovation to show developers that .NET is still a very viable platform for developers who want to build apps in this modern world,” he said. With the .NET native ahead-of-time compiler, developers will see faster startup times, lower memory usage and overall better performance, Microsoft promises. This new feature is currently in preview and allows developers to target both the X64 and ARM platforms.
You can try it out (preview only at the moment, and possibly only working for 'universal' apps so YMMV as to how useful it is), more info is available on MSDN
Upvotes: 0