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); }
private void runSerializationBenchmark(String taskName, PojoCodec codec, Object object) throws IOException { final byte[] buffer = new byte[1024]; stopWatch.start(taskName); long start = System.currentTimeMillis(); int count = 0; while (System.currentTimeMillis() - start < TEST_DURATION_MILLIS) { for (int i = 0; i < ITERATIONS; i++) { final Output output = new Output(buffer, -1); codec.serialize(object, output); count++; } } stopWatch.stop(); counts.put(taskName, count); }