commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r897623 - /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java
Date Sun, 10 Jan 2010 12:01:54 GMT
Author: sebb
Date: Sun Jan 10 12:01:53 2010
New Revision: 897623

URL: http://svn.apache.org/viewvc?rev=897623&view=rev
Log:
TEMP HACK: use nanoTime (Java 1.5+) to get better timer granularity

Modified:
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java?rev=897623&r1=897622&r2=897623&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java Sun
Jan 10 12:01:53 2010
@@ -685,7 +685,7 @@
 
     protected void multipleThreads(final int holdTime, final boolean expectError, long maxWait)
             throws Exception {
-                long startTime = System.currentTimeMillis();
+                long startTime = timeStamp();
                 final PoolTest[] pts = new PoolTest[2 * getMaxActive()];
                 // Catch Exception so we can stop all threads if one fails
                 ThreadGroup threadGroup = new ThreadGroup("foo") {
@@ -732,7 +732,7 @@
                     }
                 }
             
-                long time = System.currentTimeMillis() - startTime;
+                long time = timeStamp() - startTime;
                 System.out.println("Multithread test time = " + time
                         + " ms. Threads: " + pts.length
                         + ". Hold time: " + holdTime
@@ -756,6 +756,7 @@
                                     + ". Loops: " + pt.loops
                                     + ". State: " + pt.state
                                     + ". thrown: "+ pt.thrown
+                                    + ". (using nanoTime)"
                                     );
                         }                        
                     }
@@ -811,7 +812,7 @@
             thread =
                 new Thread(threadGroup, this, "Thread+" + currentThreadCount++);
             thread.setDaemon(false);
-            created = System.currentTimeMillis();
+            created = timeStamp();
         }
 
         public void start(){
@@ -819,14 +820,14 @@
         }
 
         public void run() {
-            started = System.currentTimeMillis();
+            started = timeStamp();
             try {
                 while (isRun) {
                     loops++;
                     state = "Getting Connection";
-                    preconnected = System.currentTimeMillis();
+                    preconnected = timeStamp();
                     Connection conn = getConnection();
-                    connected = System.currentTimeMillis();
+                    connected = timeStamp();
                     state = "Using Connection";
                     assertNotNull(conn);
                     PreparedStatement stmt =
@@ -855,7 +856,7 @@
                     throw new RuntimeException();
                 }
             } finally {
-                ended = System.currentTimeMillis();                
+                ended = timeStamp();                
             }
         }
 
@@ -867,4 +868,8 @@
             return thread;
         }
     }
+
+    long timeStamp() {
+        return System.nanoTime() / 1000000;
+    }
 }



Mime
View raw message