he he he it seems the garbage collection and object generation is real :)
marc f > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] On > Behalf Of Bill Burke > Sent: Wednesday, September 11, 2002 12:00 AM > To: Jboss-Dev > Subject: [JBoss-dev] is pooling useless? > > > I was looking into pooling Invocation objects so I thought > I'd test to see if it is actually better. With this test > case, its about 4% faster to pool on JDK 1.3.1 Win2k. > > With JDK 1.4.0 on Win2k, Non-pooling is actually 7% faster!!!!! > > import java.util.*; > > > public class testpool > { > HashMap trans; > HashMap as; > HashMap pay; > > public testpool() > { > trans = new HashMap(); > as = new HashMap(); > pay = new HashMap(); > } > public void clear() > { > trans.clear(); > as.clear(); > pay.clear(); > } > > public void addStuff() > { > for (int i = 0; i < 5; i++) > { > trans.put(new Integer(i), new Integer(i)); > as.put(new Integer(i), new Integer(i)); > pay.put(new Integer(i), new Integer(i)); > } > } > > public static LinkedList pool = new LinkedList(); > > public static void main(String[] args) > { > long start; > long end; > > System.out.println("testing non pool"); > start = System.currentTimeMillis(); > for (int i = 0; i < 1000000; i++) > { > testpool p = new testpool(); > p.addStuff(); > } > end = System.currentTimeMillis() - start; > System.out.println("time: " + end); > > System.out.println("testing pool"); > start = System.currentTimeMillis(); > for (int i = 0; i < 1000000; i++) > { > testpool p = null; > if (pool.isEmpty()) p = new testpool(); > else > { > synchronized(pool) > { > p = (testpool)pool.removeFirst(); > } > } > if (p == null) p = new testpool(); > > p.addStuff(); > p.clear(); > synchronized(pool) > { > pool.add(p); > } > } > end = System.currentTimeMillis() - start; > System.out.println("time: " + end); > } > }} > > > > ------------------------------------------------------- > In remembrance > www.osdn.com/911/ _______________________________________________ > Jboss-development mailing list [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-development > ------------------------------------------------------- In remembrance www.osdn.com/911/ _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
