public JacksonTypesBenchmark(String jsonString) throws IOException { Preconditions.checkNotNull(jsonString, "jsonString must have a value"); this.jsonString = jsonString; this.objectMapper = defaultObjectMapper(); this.factor = 10; this.cycles = 10000; // warm things up JsonType[] types = buildTypes(); for (JsonType type : types) { type.runRead(1000); type.runWrite(1000); } this.types = buildTypes(); }
/** * Runs the test. Will run <tt>factor * cycles</tt> iterations interleaving the different type * operations by <tt>factor</tt>. */ public void run() throws IOException { // interleave the type tests so GC won't be taken into account for (int i = 0; i < factor; i++) { for (JsonType type : types) { type.runRead(cycles); type.runWrite(cycles); } } System.out.println("Run [" + (cycles * factor) + "] iterations"); System.out.println("=============================="); for (JsonType type : types) { System.out.println("------------------------------"); System.out.println("Type [" + type.type.getSimpleName() + "]"); System.out.println(type.readStopWatch.shortSummary()); System.out.println(type.writeStopWatch.shortSummary()); System.out.println("------------------------------"); } }