static <T> byte[] toByteArrayBufferedProtobuf(T message, Schema<T> schema)
    {
        final ProtobufOutput output = new ProtobufOutput(new LinkedBuffer(BUF_SIZE));
        try
        {
            schema.writeTo(output, message);
        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }

        return output.toByteArray();
    }
Benchmark to compare the serialization speed of 3 types. CodedOutput, BufferedOutput and DeferredOutput.

@author David Yu
@created Nov 13, 2009
protostuff-core/src/test/java/io/protostuff/CompareOutputsTest.java