In a current project of mine, it takes about 4.8 seconds to configure NHibernate and create the session factory. Of this, about 1.8 seconds are the first (and only) instantiation of XmlSerializer(typeof(HbmMapping)); in Configuration.cs. Timings are measured with the Stopwatch class.
I can create an NHibernate.XmlSerializers.dll with this incantation: sgen /a:NHibernate.dll /t:NHibernate.Cfg.MappingSchema.HbmMapping /force /compiler:/keyfile:NHibernate.snk With this assembly available, the time to instantiate XmlSerializer(typeof(HbmMapping)); drops to only 7 ms, i.e. saving me almost two seconds for application startup. (The 7 ms are probable mostly IO and JIT - if a create the session factory again in the same process, creating the XmlSerializer drops to less than 0.7 ms.) While generating NHibernate.XmlSerializers.dll is fairly easy, it would perhaps be a good idea if the ordinary build procedure would do this, and include it in the binary package? The fixed issue http://216.121.112.228/browse/NH-2425 speaks of caching the XmlSerializer, and maybe that change was a good idea, but I'm sceptical regarding if it made much of a difference, given the numbers above. /Oskar
