Skip to content

Commit e346def

Browse files
committed
Enable mock DB for benchmarks
This reduces jitter and makes it more easy to analyze profiles of the benchmark, as only agent code is executed.
1 parent 3d9b6f8 commit e346def

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

apm-agent-benchmarks/src/main/java/co/elastic/apm/benchmark/ElasticApmContinuousBenchmark.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747
import javax.servlet.http.HttpServletResponse;
4848
import java.net.InetSocketAddress;
4949
import java.sql.Connection;
50-
import java.sql.DriverManager;
5150
import java.sql.PreparedStatement;
52-
import java.sql.SQLException;
5351
import java.util.Arrays;
5452
import java.util.Collections;
5553
import java.util.Enumeration;
@@ -110,7 +108,7 @@ public ElasticApmContinuousBenchmark(boolean apmEnabled) {
110108
}
111109

112110
@Setup
113-
public void setUp(Blackhole blackhole) throws SQLException {
111+
public void setUp(Blackhole blackhole) {
114112
server = Undertow.builder()
115113
.addHttpListener(0, "127.0.0.1")
116114
.setHandler(exchange -> {
@@ -135,11 +133,7 @@ public void setUp(Blackhole blackhole) throws SQLException {
135133
final BlackholeConnection blackholeConnection = BlackholeConnection.INSTANCE;
136134
blackholeConnection.init(blackhole);
137135

138-
Connection connection = DriverManager.getConnection("jdbc:h2:mem:test", "user", "");
139-
connection.createStatement().execute("CREATE TABLE IF NOT EXISTS ELASTIC_APM (FOO INT, BAR VARCHAR(255))");
140-
connection.createStatement().execute("INSERT INTO ELASTIC_APM (FOO, BAR) VALUES (1, 'APM')");
141-
142-
httpServlet = new BenchmarkingServlet(connection, tracer, blackhole);
136+
httpServlet = new BenchmarkingServlet(blackholeConnection, tracer, blackhole);
143137
}
144138

145139
@TearDown

0 commit comments

Comments
 (0)