protected final double _testRawDeser(int reps, byte[] json, ObjectReader reader) throws IOException { long start = System.nanoTime(); final JsonFactory f = reader.getFactory(); while (--reps >= 0) { JsonParser p = f.createParser(new ByteArrayInputStream(json)); JsonToken t; while ((t = p.nextToken()) != null) { if (t == JsonToken.VALUE_STRING) { p.getText(); } else if (t.isNumeric()) { p.getNumberValue(); } ; } p.close(); } hash = f.hashCode(); return _msecsFromNanos(System.nanoTime() - start); }
public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: java [input]"); System.exit(1); } byte[] data = readAll(args[0]); JsonFactory f = new JsonFactory(); boolean doIntern = true; f.configure(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, doIntern); f.configure(JsonFactory.Feature.INTERN_FIELD_NAMES, doIntern); ObjectMapper m = new ObjectMapper(); Object input1 = m.readValue(data, Object.class); JsonNode input2 = m.readTree(data); new ManualReadPerfUntypedStream() .testFromBytes( // .testFromString( m, "JSON-as-Object", input1, Object.class, m, "JSON-as-Object2", input2, Object.class // ,m, "JSON-as-Node", input2, JsonNode.class ); }