db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r469549 - in /db/ojb/trunk/src/test/org/apache/ojb/compare: OJBPerfTest.java PerformanceODMGTest.java
Date Tue, 31 Oct 2006 16:50:47 GMT
Author: arminw
Date: Tue Oct 31 08:50:46 2006
New Revision: 469549

URL: http://svn.apache.org/viewvc?view=rev&rev=469549
Log:
fix, improve tests

Modified:
    db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java
    db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java

Modified: db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java?view=diff&rev=469549&r1=469548&r2=469549
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java Tue Oct 31 08:50:46 2006
@@ -25,6 +25,7 @@
 import org.odmg.ODMGException;
 import org.odmg.OQLQuery;
 import org.odmg.Transaction;
+import org.odmg.QueryException;
 
 /**
  * Multi-threaded performance test implementation classes for testing
@@ -254,6 +255,7 @@
     }
 
 
+
     // =====================================================================================
     // Inner class, test handle using PB-api
     // =====================================================================================
@@ -498,16 +500,15 @@
 
         public int articleCount()
         {
-            Criteria c = new Criteria();
-            Query q = QueryFactory.newQuery(PerfArticleImpl.class, c);
             int count = 0;
+            String select = "select all from " +PerfArticleImpl.class.getName();
+            OQLQuery query = odmg.newOQLQuery();
             try
             {
-                PersistenceBroker broker = ojbInstance.lookupBroker();
-                count = broker.getCount(q);
-                broker.close();
+                query.create(select);
+                count = ((Collection) query.execute()).size();
             }
-            catch(Exception e)
+            catch(QueryException e)
             {
                 e.printStackTrace();
             }

Modified: db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java?view=diff&rev=469549&r1=469548&r2=469549
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java Tue Oct 31 08:50:46
2006
@@ -4,6 +4,8 @@
 import java.util.Iterator;
 
 import org.apache.ojb.broker.TestHelper;
+import org.apache.ojb.broker.PersistenceBroker;
+import org.apache.ojb.broker.Identity;
 import org.apache.ojb.odmg.TransactionExt;
 import org.odmg.Database;
 import org.odmg.Implementation;
@@ -116,16 +118,15 @@
         tx.setImplicitLocking(false);
         // the odmg-api hasn't specific methods to lookup objects
         // by primary key. It's recommended to use use PB-api instead for
-        // best performance. But here we use an oql-query for each object.
-        String sql = "select allArticles from " + PerformanceArticle.class.getName() + "
where articleId=$1";
+        // best performance.
         long start = System.currentTimeMillis();
         tx.begin();
+        PersistenceBroker pb = tx.getBroker();
         for(int i = 0; i < articleCount; i++)
         {
-            OQLQuery query = odmg.newOQLQuery();
-            query.create(sql);
-            query.bind(arr[i].getArticleId());
-            query.execute();
+            Identity oid = pb.serviceIdentity().
+                    buildIdentity(PerformanceArticle.class, arr[i].getArticleId());
+            pb.getObjectByIdentity(oid);
         }
         tx.commit();
         long stop = System.currentTimeMillis();
@@ -145,6 +146,9 @@
         // we don't want implicite locks when compare performance
         tx.setImplicitLocking(false);
         tx.begin();
+        // clear cache to read from DB
+        tx.getBroker().clearCache();
+
         long start = System.currentTimeMillis();
         OQLQuery query = odmg.newOQLQuery();
         String sql = "select allArticles from " + PerformanceArticle.class.getName()
@@ -159,6 +163,7 @@
             fetchCount++;
             iter.next();
         }
+        tx.commit();
         long stop = System.currentTimeMillis();
         logger.info("fetching " + fetchCount + " Objects: " + (stop - start) + " msec");
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message