private void runDeserializationBenchmark(String taskName, PojoCodec codec, Object object) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); codec.serialize(object, bos); byte[] buffer = bos.toByteArray(); int count = 0; stopWatch.start(taskName); long start = System.currentTimeMillis(); count = 0; while (System.currentTimeMillis() - start < TEST_DURATION_MILLIS) { for (int i = 0; i < ITERATIONS; i++) { codec.deserialize(buffer, object.getClass()); count++; } } stopWatch.stop(); counts.put(taskName, count); }