Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions benchmark/relational/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
h2:
image: oscarfonts/h2
ports:
- "9092:9092"
- "9093:9093"
volumes:
- /root/tmp
command:
- sh
- -c
- >
java -cp /opt/h2/bin/h2*.jar org.h2.tools.Server
-ifNotExists -web -webAllowOthers -webPort 9093
-tcp -tcpAllowOthers -tcpPort 9092 -baseDir /root/tmp
working_dir: /root/tmp

postgres:
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=benchmark
14 changes: 12 additions & 2 deletions benchmark/relational/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ The benchmarks are run against the following databases:

- In-memory H2
- A locally running H2 (port 9092, database name `benchmark`, user `sa`, empty password)
- A locally running Postgres (port 5432, database name `benchmark`, no user, no password)
- A locally running Postgres (port 5432, database name `benchmark`, user `postgres`, password `postgres`)

The settings can be adapted by tweaking corresponding `application-$database.properties` file in `src/main/resources`.


You can start the servers using the `docker-compose.yml` in this directory, e.g:

```
$ docker-compose up
...
h2_1_67fd6612bf08 | TCP server running at tcp://172.17.1.3:9092 (others can connect)
...
postgres_1_8849164d8017 | 2019-08-21 08:54:32.138 UTC [1] LOG: database system is ready to accept connections
...
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.infra.Blackhole;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.microbenchmark.common.AbstractMicrobenchmark;

Expand All @@ -45,6 +46,13 @@ public class JpaBenchmark extends AbstractMicrobenchmark {
EntityManager em;
JpaBookRepository repository;

public static void main(String[] args) {
JpaBenchmark bench = new JpaBenchmark();
bench.profile = "h2";
bench.setUp();
bench.findAll(new Blackhole("Today's password is swordfish. I understand instantiating Blackholes directly is dangerous."));
}

@Setup
public void setUp() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spring.datasource.url=jdbc:h2:tcp://localhost:9092/~/benchmark
spring.datasource.url=jdbc:h2:tcp://localhost:9092/~/tmp/benchmark
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.platform=h2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/benchmark
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.platform=postgres
spring.datasource.initialization-mode=always