use of com.fasterxml.jackson.core.JsonFactory in project jackson-module-afterburner by FasterXML.
the class TestDeserializePerf method main.
public static void main(String[] args) throws Exception {
// JsonFactory f = new org.codehaus.jackson.smile.SmileFactory();
JsonFactory f = new JsonFactory();
ObjectMapper mapperSlow = new ObjectMapper(f);
ObjectMapper mapperFast = new ObjectMapper(f);
// !!! TEST -- to get profile info, comment out:
// mapperSlow.registerModule(new AfterburnerModule());
mapperFast.registerModule(new AfterburnerModule());
new TestDeserializePerf().testWith(mapperSlow, mapperFast);
}
use of com.fasterxml.jackson.core.JsonFactory in project jackson-module-afterburner by FasterXML.
the class TestJvmDeserPerf method test.
public void test() throws Exception {
int sum = 0;
final MediaItem item = buildItem();
JsonFactory jsonF = // new org.codehaus.jackson.smile.SmileFactory();
new JsonFactory();
final ObjectMapper jsonMapper = new ObjectMapper(jsonF);
jsonMapper.registerModule(new com.fasterxml.jackson.module.afterburner.AfterburnerModule());
byte[] json = jsonMapper.writeValueAsBytes(item);
System.out.println("Warmed up: data size is " + json.length + " bytes; " + REPS + " reps -> " + ((REPS * json.length) >> 10) + " kB per iteration");
System.out.println();
int round = 0;
while (true) {
// try { Thread.sleep(100L); } catch (InterruptedException ie) { }
round = (round + 1) % 2;
long curr = System.currentTimeMillis();
String msg;
boolean lf = (round == 0);
switch(round) {
case 0:
msg = "Deserialize/databind, JSON";
sum += testDeser(jsonMapper, json, REPS);
break;
case 1:
msg = "Deserialize/manual, JSON";
sum += testDeser(jsonMapper.getFactory(), json, REPS);
break;
default:
throw new Error("Internal error");
}
curr = System.currentTimeMillis() - curr;
if (lf) {
System.out.println();
}
System.out.println("Test '" + msg + "' -> " + curr + " msecs (" + (sum & 0xFF) + ").");
}
}
use of com.fasterxml.jackson.core.JsonFactory in project jackson-core by FasterXML.
the class TestParserOverrides method testTokenAccess.
/*
/**********************************************************
/* Wrappers, to test stream and reader-based parsers
/**********************************************************
*/
public void testTokenAccess() throws Exception {
JsonFactory jf = new JsonFactory();
_testTokenAccess(jf, false);
_testTokenAccess(jf, true);
}
use of com.fasterxml.jackson.core.JsonFactory in project jackson-core by FasterXML.
the class TestJDKSerializability method testJsonFactorySerializable.
public void testJsonFactorySerializable() throws Exception {
JsonFactory f = new JsonFactory();
String origJson = "{\"simple\":[1,true,{}]}";
assertEquals(origJson, _copyJson(f, origJson, false));
// Ok: freeze dry factory, thaw, and try to use again:
byte[] frozen = jdkSerialize(f);
JsonFactory f2 = jdkDeserialize(frozen);
assertNotNull(f2);
assertEquals(origJson, _copyJson(f2, origJson, false));
// Let's also try byte-based variant, for fun...
assertEquals(origJson, _copyJson(f2, origJson, true));
}
use of com.fasterxml.jackson.core.JsonFactory in project jackson-core by FasterXML.
the class TestJDKSerializability method testLocation.
public void testLocation() throws Exception {
JsonFactory jf = new JsonFactory();
JsonParser jp = jf.createParser(" { }");
assertToken(JsonToken.START_OBJECT, jp.nextToken());
JsonLocation loc = jp.getCurrentLocation();
byte[] stuff = jdkSerialize(loc);
JsonLocation loc2 = jdkDeserialize(stuff);
assertNotNull(loc2);
assertEquals(loc.getLineNr(), loc2.getLineNr());
assertEquals(loc.getColumnNr(), loc2.getColumnNr());
jp.close();
}
Aggregations