bartoszlenar / Validot

Validot is a performance-first, compact library for advanced model validation. Using a simple declarative fluent interface, it efficiently handles classes, structs, nested members, collections, nullables, plus any relation or combination of them. It also supports translations, custom logic extensions with tests, and DI containers.
MIT License
310 stars 19 forks source link

Update the FluentValidation fail-fast comparison. #7

Closed JeremySkinner closed 4 years ago

JeremySkinner commented 4 years ago

Hi @bartoszlenar,

The "fail-fast" comparison with FV wasn't completely accurate as StopOnFirstFailure doesn't actually perform fail-fast at validator-level (only at rule-level). We added a true fail-fast option with the 9.1 release (see https://jeremyskinner.co.uk/2020/08/08/fluentvalidation-91-released/ for details), so thought I'd update your comparison too :)

bartoszlenar commented 4 years ago

Oh! Thank you, @JeremySkinner!

I'll update the results in the README file soon.

JeremySkinner commented 4 years ago

@bartoszlenar Thanks for merging this! One thing I did notice is that the IsValid_FluentValidation benchmark also uses the fail-fast behaviour (as well as the FailFast_FluentValidation benchmark). Unless I'm misunderstanding, I think the failfast behaviour should be removed from that one (probably means its performing better than it should!)

Would you also mind if I used your benchmarks as a basis to do some memory profiling & optimisation for FV?

bartoszlenar commented 4 years ago

@JeremySkinner Correct, fail-fast is used in IsValid_FluentValidation and correct, it performs better than it would if I focus on "IsValid" only :).

IMHO the direct comparison between IsValid wouldn't be fair. In Validot, IsValid is a separate mode that validates the model unless the first error is found. No further processing is needed. In FV, IsValid is just a flag over the detected error set (https://github.com/FluentValidation/FluentValidation/blob/master/src/FluentValidation/Results/ValidationResult.cs#L34).

So, to be entirely fair and for the sake of healthy competition, I tried to find the best way to reflect the Validot's logic using FV public api, and this is what I came up with.

When it comes to reusing my benchmarks, you're very welcome, take them, and use them as you want. If you create some new test data set, representative for some interesting corner cases, I would also appreciate sharing it so I can include them in Validot's tests as well.

JeremySkinner commented 4 years ago

Thanks!