use of org.infinispan.protostream.domain.User in project protostream by infinispan.
the class AnnotationsPerformanceTest method testReadWrite.
@Test
public void testReadWrite() throws Exception {
SerializationContext ctx1 = createCtxWithHandWrittenMarshaller();
SerializationContext ctx2 = createCtxWithGeneratedMarshaller();
User user = new User();
user.setId(1);
user.setName("John");
user.setSurname("Batman");
user.setSalutation("Sir");
user.setGender(User.Gender.MALE);
user.setAccountIds(new HashSet<>(Arrays.asList(1, 3)));
List<Address> addresses = new ArrayList<>();
addresses.add(new Address("Old Street", "XYZ42", -12));
addresses.add(new Address("Bond Street", "QQ42", 312));
user.setAddresses(addresses);
Note note = new Note();
note.setText("Lorem Ipsum");
note.setCreationDate(new Date());
note.setDigest(new byte[10]);
note.setBlurb(new byte[3]);
note.setAuthor(user);
Note note2 = new Note();
note2.setText("Lorem Ipsum");
note2.setAuthor(user);
note2.setBlurb(new byte[3]);
Note note3 = new Note();
note3.setText("Lorem Ipsum");
note3.setAuthor(user);
note3.setBlurb(new byte[3]);
note.note = note2;
note.notes = Collections.singletonList(note3);
byte[] bytes = writeWithProtoStream(ctx1, note);
writeWithProtoStream(ctx2, note);
long d1 = readWithProtoStream(ctx1, bytes);
log.infof("ProtoStream read duration = %d ns", d1);
long d2 = readWithProtoStream(ctx2, bytes);
log.infof("ProtoStream read duration = %d ns", d2);
}
use of org.infinispan.protostream.domain.User in project protostream by infinispan.
the class PerformanceTest method testProtoStreamWrite.
@Test
public void testProtoStreamWrite() throws Exception {
User user = createTestObject();
long[] results = new long[1];
for (int i = 0; i < NUM_OUTER_LOOPS; i++) {
log.infof("----------------------- # %d ------------------------", i);
byte[] bytes = writeWithProtoStream(user, results);
log.infof("ProtoStream payload length = %d bytes", bytes.length);
}
}
use of org.infinispan.protostream.domain.User in project protostream by infinispan.
the class PerformanceTest method testProtoStreamRead.
@Test
public void testProtoStreamRead() throws Exception {
User user = createTestObject();
long[] results = new long[1];
byte[] bytes = writeWithProtoStream(user, results);
for (int i = 0; i < NUM_OUTER_LOOPS; i++) {
log.infof("---------------------- # %d -------------------------", i);
readWithProtoStream(bytes, results);
}
}
use of org.infinispan.protostream.domain.User in project protostream by infinispan.
the class PerformanceTest method createTestObject.
private User createTestObject() {
User user = new User();
user.setId(1);
user.setName("John");
user.setSurname("Batman");
user.setGender(User.Gender.MALE);
user.setAccountIds(new HashSet<>(Arrays.asList(1, 3)));
List<Address> addresses = new ArrayList<>();
addresses.add(new Address("Old Street", "XYZ42", -12));
addresses.add(new Address("Bond Street", "QQ42", 312));
user.setAddresses(addresses);
return user;
}
use of org.infinispan.protostream.domain.User in project protostream by infinispan.
the class WrappingTest method createUser.
private User createUser(int id, String name, String surname) {
User user = new User();
user.setId(id);
user.setName(name);
user.setSurname(surname);
user.setGender(User.Gender.MALE);
user.setAccountIds(new HashSet<>(Arrays.asList(1, 3)));
user.setAddresses(Collections.singletonList(new Address("Old Street", "XYZ42", -12)));
return user;
}
Aggregations