There are 2 modes by which the CLR emits the JIT code while executing static type constructor
1) Precise mode
2) Before - field - Init ModeIn Precise mode - the code will be Jitted just beofe the first initialization/access call to a static variable
In Before - field - Init Mode - it will be Jitted during the first instance creation of the type Hence, Before field init mode is much more performant intent than the precise mode,as shown below
public class BeforInitMode
{
static int i = 20;
}
In before init Mode - type constructor is jittted much before the static member variable initialization/access
public class PreciseMode
{
static int i;
static PreciseMode()
{ i = 20;
}
}
Ref: CLR via C# by Jeffrey
I hope this helps!.
Regards,
-Vinayak
Tuesday, December 21, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment