Performance test


Here is a way for you to test what is the data sized to be transfered via DMT framework vs Default Java Serialization:


In your test class path include dmt_{version}_testutil.jar

Here is the test case template you can use:

import  org.dmdf.dmt.__DMTTestUtil;
import junit.framework.TestCase;
import java.io.Externalizable;

public class MyDMTTest extends TestCase {
     public void testDataLength() throws Exception {
                Externalizable myData = getMyTestData(); //Your object graph need to be transported
                int dmtTransportLength = new DMT("mySchema").encode(myData).getData().length;
                int serailizableLength = __DMTTestUtil.serializableBinaryLength(myData);

              assertTrue("length efficiency", (dmtTransportLength/serailizableLength)<0.6);
             System.out.println("use DMT mySchema transport, the data length="+dmtTransportLength+", use Default Java Serialzation transport, the data length="+serailizableLength+".");
  }
}


Or if you prefere not use Junit Test case:

import java.io.Externalizable;

import org.dmdf.dmt.DMT;
import org.dmdf.dmt.__DMTTestUtil;

public class MyTest {

    public static void main(String[] args) throws Exception {
        Externalizable myData = getMyTestData(); // Your object graph need to
                                                    // be transported

        int dmtTransportLength = new DMT("mySchema").encode(myData).getData().length;
        int serailizableLength = __DMTTestUtil.serializableBinaryLength(myData);

        System.out.println("use DMT mySchema transport, the data length=" + dmtTransportLength
                + ", use Default Java Serialzation transport, the data length=" + serailizableLength + ".");
    }
}