Skip to content

Commit 836b4e5

Browse files
marko-bekhtagsmet
authored andcommitted
HV-1586 Move model preparation in CascadedValidation to state preparation
1 parent 4f0c69d commit 836b4e5

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

performance/src/main/java/org/hibernate/validator/performance/cascaded/CascadedValidation.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,22 @@ public class CascadedValidation {
3939
@State(Scope.Benchmark)
4040
public static class CascadedValidationState {
4141
public volatile Validator validator;
42+
public volatile Person person;
4243

4344
public CascadedValidationState() {
4445
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
4546
validator = factory.getValidator();
47+
48+
// TODO graphs needs to be generated and deeper
49+
Person kermit = new Person( "kermit" );
50+
Person piggy = new Person( "miss piggy" );
51+
Person gonzo = new Person( "gonzo" );
52+
53+
kermit.addFriend( piggy ).addFriend( gonzo );
54+
piggy.addFriend( kermit ).addFriend( gonzo );
55+
gonzo.addFriend( kermit ).addFriend( piggy );
56+
57+
person = kermit;
4658
}
4759
}
4860

@@ -54,22 +66,13 @@ public CascadedValidationState() {
5466
@Warmup(iterations = 10)
5567
@Measurement(iterations = 20)
5668
public void testCascadedValidation(CascadedValidationState state, Blackhole bh) {
57-
// TODO graphs needs to be generated and deeper
58-
Person kermit = new Person( "kermit" );
59-
Person piggy = new Person( "miss piggy" );
60-
Person gonzo = new Person( "gonzo" );
61-
62-
kermit.addFriend( piggy ).addFriend( gonzo );
63-
piggy.addFriend( kermit ).addFriend( gonzo );
64-
gonzo.addFriend( kermit ).addFriend( piggy );
65-
66-
Set<ConstraintViolation<Person>> violations = state.validator.validate( kermit );
69+
Set<ConstraintViolation<Person>> violations = state.validator.validate( state.person );
6770
assertThat( violations ).hasSize( 0 );
6871

6972
bh.consume( violations );
7073
}
7174

72-
public class Person {
75+
public static class Person {
7376
@NotNull
7477
String name;
7578

0 commit comments

Comments
 (0)