-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBetweenBenchmark.cs
More file actions
35 lines (30 loc) · 814 Bytes
/
BetweenBenchmark.cs
File metadata and controls
35 lines (30 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace PerformanceBenchmarks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using CodingFlow.FluentValidation.Validators;
using static CodingFlow.FluentValidation.Validations;
// begin-snippet: PerformanceBenchmarkBetweenInclusive
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net10_0)]
[SimpleJob(RuntimeMoniker.Net90)]
[SimpleJob(RuntimeMoniker.Net80)]
public class BetweenBenchmark
{
private readonly int input = 5;
private readonly IntegerValidator validator = new();
[Benchmark]
public bool CodingFlow()
{
return RuleFor(input)
.BetweenInclusive(1, 7)
.Result()
.IsValid;
}
[Benchmark]
public bool FluentValidation()
{
return validator.Validate(input)
.IsValid;
}
}
// end-snippet