From a796dfca347e6f6402f68352ec1bd0eb19b7b7cc Mon Sep 17 00:00:00 2001 From: wenshao Date: Thu, 12 May 2011 10:00:50 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0BoneCP=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.alibabatech.com/svn/druid/trunk@39 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- pom.xml | 18 ++++++++++++ .../alibaba/druid/pool/benckmark/Case0.java | 29 +++++++++++++++++-- .../alibaba/druid/pool/benckmark/Case1.java | 25 +++++++++++++++- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0b3b11d418..e6140a8248 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,18 @@ 1.2.16 provided + + org.slf4j + slf4j-api + 1.6.1 + provided + + + org.slf4j + slf4j-log4j12 + 1.6.1 + provided + @@ -109,6 +121,12 @@ 1.4 test + + com.jolbox + bonecp + 0.7.1.RELEASE + test + \ No newline at end of file diff --git a/src/test/java/com/alibaba/druid/pool/benckmark/Case0.java b/src/test/java/com/alibaba/druid/pool/benckmark/Case0.java index 99d741f4a2..74cf170fbe 100644 --- a/src/test/java/com/alibaba/druid/pool/benckmark/Case0.java +++ b/src/test/java/com/alibaba/druid/pool/benckmark/Case0.java @@ -27,6 +27,7 @@ import org.apache.commons.dbcp.BasicDataSource; import com.alibaba.druid.TestUtil; import com.alibaba.druid.pool.DruidDataSource; +import com.jolbox.bonecp.BoneCPDataSource; public class Case0 extends TestCase { @@ -39,6 +40,8 @@ public class Case0 extends TestCase { private int maxPoolSize = 2; private int maxActive = 2; private String validationQuery = null; + + public final int LOOP_COUNT = 5; protected void setUp() throws Exception { jdbcUrl = "jdbc:fake:dragoon_v25masterdb"; @@ -63,7 +66,7 @@ public class Case0 extends TestCase { dataSource.setValidationQuery(validationQuery); dataSource.setTestOnBorrow(true); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < LOOP_COUNT; ++i) { p0(dataSource, "druid"); } System.out.println(); @@ -85,11 +88,33 @@ public class Case0 extends TestCase { dataSource.setValidationQuery("SELECT 1"); dataSource.setTestOnBorrow(true); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < LOOP_COUNT; ++i) { p0(dataSource, "dbcp"); } System.out.println(); } + + public void test_2() throws Exception { + BoneCPDataSource dataSource = new BoneCPDataSource(); + // dataSource.(10); + // dataSource.setMaxActive(50); + dataSource.setMinConnectionsPerPartition(minPoolSize); + dataSource.setMaxConnectionsPerPartition(maxPoolSize); + + dataSource.setDriverClass(driverClass); + dataSource.setJdbcUrl(jdbcUrl); + // dataSource.setPoolPreparedStatements(true); + // dataSource.setMaxOpenPreparedStatements(100); + dataSource.setUsername(user); + dataSource.setPassword(password); + dataSource.setConnectionTestStatement("SELECT 1"); + dataSource.setPartitionCount(1); + + for (int i = 0; i < LOOP_COUNT; ++i) { + p0(dataSource, "boneCP"); + } + System.out.println(); + } private void p0(DataSource dataSource, String name) throws SQLException { long startMillis = System.currentTimeMillis(); diff --git a/src/test/java/com/alibaba/druid/pool/benckmark/Case1.java b/src/test/java/com/alibaba/druid/pool/benckmark/Case1.java index 9216df1fdf..c52058de5d 100644 --- a/src/test/java/com/alibaba/druid/pool/benckmark/Case1.java +++ b/src/test/java/com/alibaba/druid/pool/benckmark/Case1.java @@ -27,6 +27,7 @@ import org.apache.commons.dbcp.BasicDataSource; import com.alibaba.druid.TestUtil; import com.alibaba.druid.pool.DruidDataSource; +import com.jolbox.bonecp.BoneCPDataSource; public class Case1 extends TestCase { @@ -39,7 +40,7 @@ public class Case1 extends TestCase { private int maxPoolSize = 2; private int maxActive = 2; private String validationQuery = "SELECT 1"; - private int threadCount = 20; + private int threadCount = 2; private int loopCount = 5; protected void setUp() throws Exception { @@ -92,6 +93,28 @@ public class Case1 extends TestCase { } System.out.println(); } + + public void test_2() throws Exception { + BoneCPDataSource dataSource = new BoneCPDataSource(); + // dataSource.(10); + // dataSource.setMaxActive(50); + dataSource.setMinConnectionsPerPartition(minPoolSize); + dataSource.setMaxConnectionsPerPartition(maxPoolSize); + + dataSource.setDriverClass(driverClass); + dataSource.setJdbcUrl(jdbcUrl); + // dataSource.setPoolPreparedStatements(true); + // dataSource.setMaxOpenPreparedStatements(100); + dataSource.setUsername(user); + dataSource.setPassword(password); + dataSource.setConnectionTestStatement("SELECT 1"); + dataSource.setPartitionCount(1); + + for (int i = 0; i < loopCount; ++i) { + p0(dataSource, "boneCP", threadCount); + } + System.out.println(); + } private void p0(final DataSource dataSource, String name, int threadCount) throws Exception {