From 45cd785cb2b8df1c5b6ced7824adb49dfb3fa791 Mon Sep 17 00:00:00 2001 From: Brett Wooldridge Date: Tue, 10 Dec 2013 13:01:10 +0900 Subject: [PATCH] Add tomcat-jdbc to benchmark. --- benchmark.sh | 9 ++++-- core/pom.xml | 12 +++++++ .../zaxxer/hikari/performance/Benchmark1.java | 31 ++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/benchmark.sh b/benchmark.sh index dfd1bb60..805435e1 100755 --- a/benchmark.sh +++ b/benchmark.sh @@ -3,11 +3,16 @@ CLASSPATH=$CLASSPATH:~/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar CLASSPATH=$CLASSPATH:~/.m2/repository/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar CLASSPATH=$CLASSPATH:~/.m2/repository/org/slf4j/slf4j-simple/1.7.5/slf4j-simple-1.7.5.jar + CLASSPATH=$CLASSPATH:~/.m2/repository/com/jolbox/bonecp/0.8.0-rc3/bonecp-0.8.0-rc3.jar CLASSPATH=$CLASSPATH:~/.m2/repository/com/google/guava/guava/15.0/guava-15.0.jar + +CLASSPATH=$CLASSPATH:~/.m2/repository/org/apache/tomcat/tomcat-jdbc/7.0.47/tomcat-jdbc-7.0.47.jar +CLASSPATH=$CLASSPATH:~/.m2/repository/org/apache/tomcat/tomcat-juli/7.0.47/tomcat-juli-7.0.47.jar + CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar -CLASSPATH=$CLASSPATH:./core/target/HikariCP-1.1.9-SNAPSHOT.jar -CLASSPATH=$CLASSPATH:./agent/target/HikariCP-agent-1.1.9-SNAPSHOT.jar +CLASSPATH=$CLASSPATH:./core/target/HikariCP-1.2.2-SNAPSHOT.jar +CLASSPATH=$CLASSPATH:./agent/target/HikariCP-agent-1.2.2-SNAPSHOT.jar CLASSPATH=$CLASSPATH:./core/target/test-classes java -classpath $CLASSPATH \ diff --git a/core/pom.xml b/core/pom.xml index a3df0ef2..179b5fa2 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -123,6 +123,18 @@ 0.9.1.2 test + + org.apache.tomcat + tomcat-jdbc + 7.0.47 + test + + + tomcat + tomcat-juli + 5.5.23 + test + diff --git a/core/src/test/java/com/zaxxer/hikari/performance/Benchmark1.java b/core/src/test/java/com/zaxxer/hikari/performance/Benchmark1.java index 6334c098..057f11c0 100644 --- a/core/src/test/java/com/zaxxer/hikari/performance/Benchmark1.java +++ b/core/src/test/java/com/zaxxer/hikari/performance/Benchmark1.java @@ -10,6 +10,8 @@ import java.util.concurrent.TimeUnit; import javax.sql.DataSource; +import org.apache.tomcat.jdbc.pool.PoolProperties; + import snaq.db.DBPoolDataSource; import com.jolbox.bonecp.BoneCPConfig; @@ -38,7 +40,7 @@ public class Benchmark1 if (args.length < 3) { System.err.println("Usage: "); - System.err.println(" 'hikari' or 'bone'"); + System.err.println(" 'hikari', 'bone', 'dbpool', 'c3p0', 'tomcat'"); System.exit(0); } @@ -66,6 +68,11 @@ public class Benchmark1 benchmarks.ds = benchmarks.setupC3P0(); System.out.printf("Benchmarking C3P0 - %d threads, %d connections", THREADS, POOL_MAX); } + else if (args[0].equals("tomcat")) + { + benchmarks.ds = benchmarks.setupTomcat(); + System.out.printf("Benchmarking Tomcat-JDBC - %d threads, %d connections", THREADS, POOL_MAX); + } else { System.err.println("Start with one of: hikari, bone"); @@ -75,6 +82,7 @@ public class Benchmark1 System.out.println("\nMixedBench"); System.out.println(" Warming up JIT"); benchmarks.startMixedBench(100, 10000); + benchmarks.startMixedBench(100, 10000); System.out.println(" MixedBench Final Timing Runs"); benchmarks.startMixedBench(THREADS, 1000); benchmarks.startMixedBench(THREADS, 1000); @@ -238,6 +246,27 @@ public class Benchmark1 } } + private DataSource setupTomcat() + { + PoolProperties p = new PoolProperties(); + p.setUrl("jdbc:stub"); + p.setDriverClassName("com.zaxxer.hikari.performance.StubDriver"); + p.setUsername("sa"); + p.setPassword(""); + p.setInitialSize(POOL_MAX / 2); + p.setMinIdle(0); + p.setMaxIdle(POOL_MAX); + p.setMaxActive(POOL_MAX); + p.setMaxWait(8000); + p.setMinEvictableIdleTimeMillis((int) TimeUnit.MINUTES.toMillis(30)); + p.setTestOnBorrow(true); + p.setValidationQuery("VALUES 1"); + + DataSource dataSource = new org.apache.tomcat.jdbc.pool.DataSource(p); + + return dataSource; + } + private class MixedRunner implements Measurable { private CyclicBarrier barrier;