5 Replies Latest reply: Nov 10, 2006 4:43 PM by Clebert Suconic RSS

Poor performance with test...

David Castañeda Newbie

trying this...

long init = System.currentTimeMillis();
ObjectOutputStream dos = new JBossObjectOutputStream(new FileOutputStream("c:\\test.txt"));
dos.writeObject(opportunities);
dos.close();
File f = new File("c:\\test.txt");
System.out.println("result bytes = " + f.length());
System.out.println("result time = " + (System.currentTimeMillis() - init));

opportunities is an ArrayList filled with a javabean with no superclasses an using as fields primitives string and java.util.Date

with JBossObjectOutputStream has the result...
INFO: result bytes = 125880 (Constant)
INFO: result time = 828 (%)


with java.io.ObjectOutputStream has the result...
INFO: result bytes = 103723 (103723)
INFO: result time = 156 (%)

I'm doing something wrong??? as I don;t getting even the same performanceas normal serialization.

  • 1. Re: Poor performance with test...
    Clebert Suconic Master

    You always need a BufferedOutputStream and BufferedINputStream on JBossObjectOutputStream...

    even the regular ObjectOutputStream will work better with a BufferedStream

    There is another thread on this forum talking about this.


    You should do:



    long init = System.currentTimeMillis();
    ObjectOutputStream dos = new JBossObjectOutputStream (new BufferedOutputStream(new FileOutputStream("c:\\test.txt")));
    dos.writeObject(opportunities);
    dos.close();
    File f = new File("c:\\test.txt");
    System.out.println("result bytes = " + f.length());
    System.out.println("result time = " + (System.currentTimeMillis() - init));

  • 2. Re: Poor performance with test...
    Lan Ke Newbie

    I have similar experience: this package is slower than standard JDK 1.4.2 and consuming more memory. Is there something wrong on the following code snippet?


    ---------------------
    ByteArrayOutputStream bstream = new ByteArrayOutputStream();
    org.jboss.serial.io.JBossObjectOutputStream out = new org.jboss.serial.io.JBossObjectOutputStream(bstream);

    out.writeObject(obj);
    out.close();

    // Loading the memory block as an Object
    ByteArrayInputStream binstream = new ByteArrayInputStream(bstream.toByteArray());
    org.jboss.serial.io.JBossObjectInputStream oin = new org.jboss.serial.io.JBossObjectInputStream(binstream);

    Object newobj = oin.readObject();

  • 3. Re: Poor performance with test...
    Clebert Suconic Master

    You are probably measuring classLoading time...

    You need to ignore first measuring... considering only steady time.

  • 4. Re: Poor performance with test...
    Lan Ke Newbie

    The measure is taking against 1000 runs of cloning a same object, and the class loading should not be a big impact here.

    By the way, the smartClone method provided works great. On my test, it is more than twice as fast as the standard serialization.

    -------------
    ByteArrayOutputStream bstream = new ByteArrayOutputStream();
    org.jboss.serial.io.JBossObjectOutputStream out = new org.jboss.serial.io.JBossObjectOutputStream(bstream);

    Object newobj = out.smartClone(obj);

  • 5. Re: Poor performance with test...
    Clebert Suconic Master

    On the Benchmarks I have done I always ignored 100 first elements to be fair.. not computing ClassLoading as JDK classes get sometimes pre-loaded (Specially Serialization)

    Also.. I always used the same ByteArrrayOutputStream (by calling reset)...

    And of course my Java and JBoss examples were the same. I needed to be fair on both sides.