### Question:
AeronNDArraySerde extends BinarySerde { public static UnsafeBuffer toBuffer(INDArray arr) { return new UnsafeBuffer(toByteBuffer(arr)); }  static ByteBuffer getDirectByteBuffer(DirectBuffer directBuffer); static UnsafeBuffer toBuffer(INDArray arr); static Pair<INDArray, ByteBuffer> toArrayAndByteBuffer(DirectBuffer buffer, int offset); static INDArray toArray(DirectBuffer buffer, int offset); static INDArray toArray(DirectBuffer buffer);  }### Answer:
@Test public void timeOldVsNew() throws Exception { int numTrials = 1000; long oldTotal = 0; long newTotal = 0; INDArray arr = Nd4j.create(100000); Nd4j.getCompressor().compressi(arr, "GZIP"); for (int i = 0; i < numTrials; i++) { StopWatch oldStopWatch = new StopWatch(); BufferedOutputStream bos = new BufferedOutputStream(new ByteArrayOutputStream((int) arr.length())); DataOutputStream dos = new DataOutputStream(bos); oldStopWatch.start(); Nd4j.write(arr, dos); oldStopWatch.stop(); oldTotal += oldStopWatch.getNanoTime(); StopWatch newStopWatch = new StopWatch(); newStopWatch.start(); AeronNDArraySerde.toBuffer(arr); newStopWatch.stop(); newTotal += newStopWatch.getNanoTime(); } oldTotal /= numTrials; newTotal /= numTrials; System.out.println("Old avg " + oldTotal + " New avg " + newTotal); }