@Benchmark public void put() { message.put(buffer); buffer.flip(); }
@Benchmark public void formatAndPut() { format(); message.put(buffer); buffer.flip(); }
@Setup(Level.Iteration) public void prepare() { message = new FIXMessage(32, 32); format(); buffer = ByteBuffer.allocateDirect(1024); message.put(buffer); buffer.flip(); }
/** * Send a message. * * @param message a message * @throws IOException if an I/O error occurs */ public void send(FIXMessage message) throws IOException { txBodyBuffer.clear(); message.put(txBodyBuffer); bodyLength.setInt(txBodyBuffer.position()); txHeaderBuffer.position(bodyLengthOffset); bodyLength.put(txHeaderBuffer); checkSum.setCheckSum(FIXCheckSums.sum(txHeaderBuffer, 0, txHeaderBuffer.position()) + FIXCheckSums.sum(txBodyBuffer, 0, txBodyBuffer.position())); txBodyBuffer.put(CHECK_SUM); checkSum.put(txBodyBuffer); txHeaderBuffer.flip(); txBodyBuffer.flip(); int remaining = txHeaderBuffer.remaining() + txBodyBuffer.remaining(); do { remaining -= channel.write(txBuffers, 0, txBuffers.length); } while (remaining > 0); txMsgSeqNum++; lastTxMillis = currentTimeMillis; }
/** * Send a message. * * @param message a message * @throws IOException if an I/O error occurs */ public void send(FIXMessage message) throws IOException { txBodyBuffer.clear(); message.put(txBodyBuffer); bodyLength.setInt(txBodyBuffer.position()); txHeaderBuffer.clear(); FIXTags.put(txHeaderBuffer, BeginString); beginString.put(txHeaderBuffer); FIXTags.put(txHeaderBuffer, BodyLength); bodyLength.put(txHeaderBuffer); checkSum.setCheckSum(FIXCheckSums.sum(txHeaderBuffer, 0, txHeaderBuffer.position()) + FIXCheckSums.sum(txBodyBuffer, 0, txBodyBuffer.position())); FIXTags.put(txBodyBuffer, CheckSum); checkSum.put(txBodyBuffer); txHeaderBuffer.flip(); txBodyBuffer.flip(); int remaining = txHeaderBuffer.remaining() + txBodyBuffer.remaining(); do { remaining -= channel.write(txBuffers, 0, txBuffers.length); } while (remaining > 0); txMsgSeqNum++; lastTxMillis = currentTimeMillis; }