开发者

NHibernate Validator initialization is very slow with ValidatorMode.OverrideAttributeWithExternal

Is there any way of speeding up the time NHibernate Validator takes to initialize when the default validator mode is set to ValidatorMode.OverrideAttributeWithExternal?

It takes over 11 seconds to finish initialization on my pretty fast machine in my fairly small project:

FluentConfiguration con开发者_如何学Pythonfiguration = new FluentConfiguration();
    configuration
        .SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal)
        .IntegrateWithNHibernate.ApplyingDDLConstraints().RegisteringListeners();

ValidatorEngine validatorEngine =
    NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine();

validatorEngine.Configure(configuration);

// Takes 11 seconds to finish, unless the SetDefaultValidatorMode above is removed.
ValidatorInitializer.Initialize(nhibernateCfg, validatorEngine);

I have roughly 50 entities and just two validation definitions lingering around.


I have nearly the same configuration as you and my Initialize function finishes in less than a second. One of the differences I see between my configuration and yours is the following as part of my fluent configuration:

.Register(Assembly.Load("Assembly.Where.External.Internal.Attributes.Live")
           .ValidationDefinitions())

I'm not sure what NHV does by default if you don't specify this but it's worth a shot.

Also another thing you could try is to set up log4net logging in your app.config for NHV and this may help you to see where the time is being spent. I'm not sure how in depth the logging is but it may be helpful.

If all else fails you can download the source and debug through it as well.

Edit:
The below is what I use to put my NHV logging in a seperate file.

<logger name="NHibernate.Validator" additivity="false">
  <level value="DEBUG"/>
  <appender-ref ref="WhateverAppenderYouWant"/>
</logger>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜