Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 18690 invoked from network); 14 Aug 2006 14:41:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Aug 2006 14:41:43 -0000 Received: (qmail 76055 invoked by uid 500); 14 Aug 2006 14:41:43 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 76035 invoked by uid 500); 14 Aug 2006 14:41:43 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 76024 invoked by uid 500); 14 Aug 2006 14:41:43 -0000 Received: (qmail 76021 invoked by uid 99); 14 Aug 2006 14:41:43 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Aug 2006 07:41:43 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Aug 2006 07:41:42 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 5D5301A981A; Mon, 14 Aug 2006 07:41:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r431355 - /db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java Date: Mon, 14 Aug 2006 14:41:22 -0000 To: ojb-commits@db.apache.org From: arminw@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060814144122.5D5301A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: arminw Date: Mon Aug 14 07:41:21 2006 New Revision: 431355 URL: http://svn.apache.org/viewvc?rev=431355&view=rev Log: improve test Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java?rev=431355&r1=431354&r2=431355&view=diff ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java Mon Aug 14 07:41:21 2006 @@ -1,74 +1,110 @@ package org.apache.ojb.broker; -import junit.framework.TestCase; - import java.util.Map; import java.util.HashMap; import org.apache.ojb.broker.metadata.DescriptorRepository; -import org.apache.ojb.broker.metadata.MetadataManager; +import org.apache.ojb.junit.PBTestCase; /** * @author Matthew.Baird * - * To change this generated comment edit the template variable "typecomment": - * Window>Preferences>Java>Templates. - * To enable and disable the creation of type comments go to - * Window>Preferences>Java>Code Generation. + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. */ -public class IdentityPerformanceTest extends TestCase +public class IdentityPerformanceTest extends PBTestCase { - PersistenceBroker broker; - private static Class CLASS = IdentityPerformanceTest.class; - private static final int ITERATIONS = 10000; + private static final int ITERATIONS = 300000; public static void main(String[] args) { - String[] arr = {CLASS.getName()}; + String[] arr = {IdentityPerformanceTest.class.getName()}; junit.textui.TestRunner.main(arr); } - public void testIdentityIterations() + public void testIdentityHandlingPerformance() throws Exception + { + doDescriptorRepositoryGetDescriptorForIterations(); + System.gc(); + System.gc(); + //Thread.sleep(1000); + long oidCreation = doIdentityIterations(); + System.gc(); + System.gc(); + //Thread.sleep(1000); + long mapCreation = doMapIterations(); + System.gc(); + System.gc(); + + /* + This is a critical test, because we do a performance comparison + of class instantion time which strongly depends on used hardware + and JDK version. + */ +// String msg = "\n This is a critical test, because we do a performance comparison\n" + +// " of class instantiation time which strongly depends on used hardware\n" + +// " and JDK version.\n" + +// " But it seems that creation of Identity objects is a bit slow.\n" + +// " Please check source code handling Identity object creation."; +// boolean ratio = (oidCreation / mapCreation) > 10; +// System.out.println("Ratio IdentityCreation/MapCreation <==> " + oidCreation / mapCreation + ":1"); +// assertFalse(msg, ratio); + } + + public long doIdentityIterations() { Article art = new Article(); art.setArticleName("OJB O/R mapping power"); ProductGroup pg = new ProductGroup(); pg.setName("Software"); art.setProductGroup(pg); + broker.beginTransaction(); + broker.store(art); + broker.commitTransaction(); + // prime the pump. - Identity artOID = new Identity(art,broker); + broker.serviceIdentity().buildIdentity(art); long start = System.currentTimeMillis(); - for (int i = 0; i < ITERATIONS; i++) + Identity artOID; + for(int i = 0; i < ITERATIONS; i++) { - artOID = new Identity(art,broker); + artOID = broker.serviceIdentity().buildIdentity(art); + assertNotNull(artOID); } long stop = System.currentTimeMillis(); System.out.println("total time to build " + ITERATIONS + " identities " + (stop - start) + " ms."); - System.out.println("time to build one Identity " + ((stop - start) / ITERATIONS) + " ms."); + //System.out.println("time to build one Identity " + ((stop - start) / ITERATIONS) + " ms."); + return stop - start; } - public void testMapIterations() + + public long doMapIterations() { long start = System.currentTimeMillis(); Map temp; - - for (int i = 0; i < ITERATIONS; i++) + for(int i = 0; i < ITERATIONS; i++) { temp = new HashMap(); + assertNotNull(temp); } long stop = System.currentTimeMillis(); System.out.println("total time to build " + ITERATIONS + " HashMaps " + (stop - start) + " ms."); - System.out.println("time to build one HashMaps " + ((stop - start) / ITERATIONS) + " ms."); + //System.out.println("time to build one HashMaps " + ((stop - start) / ITERATIONS) + " ms."); + return stop - start; } - public void testDescriptorRepositoryGetDescriptorForIterations() + + public long doDescriptorRepositoryGetDescriptorForIterations() { long start = System.currentTimeMillis(); - DescriptorRepository descriptorRepository = MetadataManager.getInstance().getRepository(); - for (int i = 0; i < ITERATIONS; i++) + DescriptorRepository descriptorRepository = broker.getDescriptorRepository(); + for(int i = 0; i < ITERATIONS; i++) { descriptorRepository.getDescriptorFor(Article.class); } long stop = System.currentTimeMillis(); System.out.println("total time to getDescriptorFor " + ITERATIONS + " times " + (stop - start) + " ms."); - System.out.println("time to call one getDescriptorFor " + ((stop - start) / ITERATIONS) + " ms."); + //System.out.println("time to call one getDescriptorFor " + ((stop - start) / ITERATIONS) + " ms."); + return stop - start; } } --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org