|
From: <cle...@jb...> - 2006-06-06 12:59:11
|
You need to use a BufferedOutputStream
Even javaSerialization works better with the Buffer.
This is because JavaSErialization has an internal buffer. JBossSErialization not.
jboss=330
| java=351
public class MyTest extends TestCase
| {
|
| static class MyObject implements Serializable
| {
|
| Long along;
| Date adate;
| Date anotherdate;
| String astring;
| String anotherstring;
| int a;
| int b;
| boolean somea;
| int c;
| public int getA() {
| return a;
| }
| public void setA(int a) {
| this.a = a;
| }
| public Date getAdate() {
| return adate;
| }
| public void setAdate(Date adate) {
| this.adate = adate;
| }
| public Long getAlong() {
| return along;
| }
| public void setAlong(Long along) {
| this.along = along;
| }
| public Date getAnotherdate() {
| return anotherdate;
| }
| public void setAnotherdate(Date anotherdate) {
| this.anotherdate = anotherdate;
| }
| public String getAnotherstring() {
| return anotherstring;
| }
| public void setAnotherstring(String anotherstring) {
| this.anotherstring = anotherstring;
| }
| public String getAstring() {
| return astring;
| }
| public void setAstring(String astring) {
| this.astring = astring;
| }
| public int getB() {
| return b;
| }
| public void setB(int b) {
| this.b = b;
| }
| public int getC() {
| return c;
| }
| public void setC(int c) {
| this.c = c;
| }
| public boolean isSomea() {
| return somea;
| }
| public void setSomea(boolean somea) {
| this.somea = somea;
| }
| public MyObject(Long along, Date adate, Date anotherdate, String astring, String anotherstring, int a, int b, boolean somea, int c) {
| super();
| this.along = along;
| this.adate = adate;
| this.anotherdate = anotherdate;
| this.astring = astring;
| this.anotherstring = anotherstring;
| this.a = a;
| this.b = b;
| this.somea = somea;
| this.c = c;
| }
| }
|
| public static boolean useBuffer=true;
|
| public void testJBoss() throws Exception
| {
| File file=new File("/tmp/jboss.ser");
| FileOutputStream fileOutputStream=new FileOutputStream(file);
| BufferedOutputStream buffOut = new BufferedOutputStream(fileOutputStream);
| ObjectOutputStream out = null;
| if (useBuffer)
| {
| out = new JBossObjectOutputStream(buffOut);
| }
| else
| {
| out = new JBossObjectOutputStream(fileOutputStream);
| }
| final MyObject event = new MyObject(new Long(9999),new Date(),new Date(),"string1","string2",123,234,true,345);
|
| long firstTimeStamp=0;
|
| for(int i=0;i<20000;i++){
| if (i==1000)
| {
| firstTimeStamp = System.currentTimeMillis();
| }
| out.reset();
| out.writeObject(event);
| out.flush();
| }
|
|
| long timeSpent=System.currentTimeMillis()-firstTimeStamp;
| System.out.println("jboss="+timeSpent);
|
|
|
| }
| public void testJava() throws Exception
| {
| File file=new File("/tmp/java.ser");
| FileOutputStream fileOutputStream=new FileOutputStream(file);
| BufferedOutputStream buffOut = new BufferedOutputStream(fileOutputStream);
| ObjectOutputStream out = null;
| if (useBuffer)
| {
| out = new ObjectOutputStream(buffOut);
| }
| else
| {
| out = new ObjectOutputStream(fileOutputStream);
| }
| final MyObject event = new MyObject(new Long(9999),new Date(),new Date(),"string1","string2",123,234,true,345);
|
| long firstTimeStamp=0;
|
| for(int i=0;i<20000;i++){
| if (i==1000)
| {
| firstTimeStamp = System.currentTimeMillis();
| }
| out.reset();
| out.writeObject(event);
| out.flush();
| }
|
|
| long timeSpent=System.currentTimeMillis()-firstTimeStamp;
| System.out.println("java=" + timeSpent);
|
|
|
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3949352#3949352
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3949352
|