Bench { static ByteString zip(ByteString data) { try (ByteString.Output bso = ByteString.newOutput(data.size()); GZIPOutputStream zos = new GZIPOutputStream(bso, true)) { data.writeTo(zos); zos.flush(); return bso.toByteString(); } catch (IOException e) { throw new IllegalStateException(e); } }  static void main(String[] args); @Benchmark int time_build_ProtoOrtb(int reps); @Benchmark int time_buf_protoDc(int reps); @Benchmark int time_buf_protoOrtb(int reps); @Benchmark int time_json_protoOrtb(int reps); @Benchmark int time_protoDc_protoOrtb(int reps); @Benchmark int protoOrtb_buf(int reps); @Benchmark int protoOrtb_json(int reps);  }
@Test public void testRealRequest() throws IOException { NetworkBid.BidRequest dcReq = DoubleClickData.newRealRequest(); ByteString dcReqBuf = dcReq.toByteString(); DoubleClickOpenRtbMapper mapper = new DoubleClickOpenRtbMapper( new MetricRegistry(), DoubleClickTestUtil.getMetadata(), null, null, ImmutableList.<ExtMapper>of()); OpenRtb.BidRequest ortbReq = mapper.toOpenRtbBidRequest(dcReq).build(); ByteString ortbReqBuf = ortbReq.toByteString(); OpenRtbJsonWriter ortbJsonWriter = OpenRtbJsonFactory.create().newWriter(); ByteString json = ByteString.copyFromUtf8(ortbJsonWriter.writeBidRequest(ortbReq)); logger.info( "\nDoubleClick/Protobuf : {} bytes" + "\nDoubleClick/Protobuf/gzip: {} bytes" + "\nOpenRTB/Protobuf : {} bytes" + "\nOpenRTB/Protobuf/gzip : {} bytes" + "\nOpenRTB/JSON : {} bytes" + "\nOpenRTB/JSON/gzip : {} bytes" + "\n" + "\nDoubleClick/Protobuf Model:\n{}" + "\n" + "\nOpenRTB/Protobuf Model:\n{}" + "\n" + "\nOpenRTB/JSON Model:\n{}\n", dcReqBuf.size(), Bench.zip(dcReqBuf).size(), ortbReqBuf.size(), Bench.zip(ortbReqBuf).size(), json.size(), Bench.zip(json).size(), dcReq, ortbReq, json.toStringUtf8()); }