use of com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer in project oap by oaplatform.
the class ParserPerformance method performance.
@Test
public void performance() {
final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jdk8Module());
final JodaModule module = new JodaModule();
module.addDeserializer(DateTime.class, forType(DateTime.class));
module.addSerializer(DateTime.class, new DateTimeSerializer(jodaDateFormat, 0));
mapper.registerModule(module);
mapper.enable(DeserializationFeature.USE_LONG_FOR_INTS);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.registerModule(new OapJsonModule());
benchmark("mapParser-jackson", 5000, () -> mapper.writeValueAsString(mapper.readValue(yearJson, Map.class))).run();
final ObjectMapper mapper2 = new ObjectMapper();
mapper2.registerModule(new Jdk8Module());
mapper2.registerModule(module);
mapper2.enable(DeserializationFeature.USE_LONG_FOR_INTS);
mapper2.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper2.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper2.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
mapper2.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper2.registerModule(new OapJsonModule());
mapper2.registerModule(new AfterburnerModule());
benchmark("mapParser-jackson2", 5000, () -> mapper2.writeValueAsString(mapper2.readValue(yearJson, Map.class))).run();
}
Aggregations