Skip to content

Commit 2d7b628

Browse files
Add benchmark
Co-Authored-By: Johannes Rabauer <8188460+JohannesRabauer@users.noreply.github.com>
1 parent dc62f5a commit 2d7b628

13 files changed

Lines changed: 647 additions & 0 deletions

File tree

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<modules>
1818
<module>spring-data-eclipse-store</module>
1919
<module>spring-data-eclipse-store-demo</module>
20+
<module>spring-data-eclipse-store-benchmark</module>
2021
</modules>
2122

2223
<licenses>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.xdev-software</groupId>
6+
<artifactId>spring-data-eclipse-store-benchmark</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
10+
<inceptionYear>2023</inceptionYear>
11+
12+
<organization>
13+
<name>XDEV Software</name>
14+
<url>https://xdev.software</url>
15+
</organization>
16+
17+
<properties>
18+
<javaVersion>17</javaVersion>
19+
<maven.compiler.release>${javaVersion}</maven.compiler.release>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22+
23+
<spring-boot.version>3.2.2</spring-boot.version>
24+
<jmh.version>1.37</jmh.version>
25+
</properties>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>software.xdev</groupId>
30+
<artifactId>spring-data-eclipse-store</artifactId>
31+
<version>${project.version}</version>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot</artifactId>
37+
<version>${spring-boot.version}</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter</artifactId>
42+
<version>${spring-boot.version}</version>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.openjdk.jmh</groupId>
47+
<artifactId>jmh-core</artifactId>
48+
<version>${jmh.version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.openjdk.jmh</groupId>
52+
<artifactId>jmh-generator-annprocess</artifactId>
53+
<version>${jmh.version}</version>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<plugins>
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-compiler-plugin</artifactId>
62+
<version>3.12.1</version>
63+
<configuration>
64+
<release>${maven.compiler.release}</release>
65+
<annotationProcessorPaths>
66+
<path>
67+
<groupId>org.openjdk.jmh</groupId>
68+
<artifactId>jmh-generator-annprocess</artifactId>
69+
<version>${jmh.version}</version>
70+
</path>
71+
</annotationProcessorPaths>
72+
</configuration>
73+
</plugin>
74+
</plugins>
75+
</build>
76+
<profiles>
77+
<profile>
78+
<id>checkstyle</id>
79+
<build>
80+
<plugins>
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-checkstyle-plugin</artifactId>
84+
<version>3.3.1</version>
85+
<dependencies>
86+
<dependency>
87+
<groupId>com.puppycrawl.tools</groupId>
88+
<artifactId>checkstyle</artifactId>
89+
<version>10.12.7</version>
90+
</dependency>
91+
</dependencies>
92+
<configuration>
93+
<configLocation>../.config/checkstyle/checkstyle.xml</configLocation>
94+
</configuration>
95+
<executions>
96+
<execution>
97+
<goals>
98+
<goal>check</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
</plugins>
104+
</build>
105+
</profile>
106+
</profiles>
107+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package software.xdev.spring.data.eclipse.store.benchmark;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
import org.springframework.context.ConfigurableApplicationContext;
8+
9+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
10+
11+
12+
@SuppressWarnings("checkstyle:HideUtilityClassConstructor")
13+
@SpringBootApplication
14+
@EnableEclipseStoreRepositories
15+
public class BenchmarkApplication
16+
{
17+
private static final Logger LOG = LoggerFactory.getLogger(BenchmarkApplication.class);
18+
19+
public static void main(final String[] args)
20+
{
21+
try
22+
{
23+
final ConfigurableApplicationContext run = SpringApplication.run(BenchmarkRunner.class, args);
24+
run.close();
25+
}
26+
catch(final Exception e)
27+
{
28+
LOG.error("Error starting the benchmark", e);
29+
}
30+
}
31+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package software.xdev.spring.data.eclipse.store.benchmark;
2+
3+
import java.util.concurrent.TimeUnit;
4+
5+
import org.openjdk.jmh.annotations.Mode;
6+
import org.openjdk.jmh.runner.Runner;
7+
import org.openjdk.jmh.runner.RunnerException;
8+
import org.openjdk.jmh.runner.options.Options;
9+
import org.openjdk.jmh.runner.options.OptionsBuilder;
10+
import org.openjdk.jmh.runner.options.TimeValue;
11+
12+
13+
public final class BenchmarkRunner
14+
{
15+
private BenchmarkRunner()
16+
{
17+
}
18+
19+
@SuppressWarnings("checkstyle:MagicNumber")
20+
public static void main(final String[] args) throws RunnerException
21+
{
22+
final Options opt = new OptionsBuilder()
23+
.mode(Mode.AverageTime)
24+
.forks(1)
25+
.warmupTime(TimeValue.seconds(1))
26+
.warmupIterations(8)
27+
.measurementTime(TimeValue.seconds(1))
28+
.measurementIterations(10)
29+
.timeUnit(TimeUnit.MILLISECONDS)
30+
.build();
31+
32+
new Runner(opt).run();
33+
}
34+
}
35+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package software.xdev.spring.data.eclipse.store.benchmark;
2+
3+
import java.io.IOException;
4+
import java.nio.file.Files;
5+
import java.nio.file.Path;
6+
7+
import org.openjdk.jmh.annotations.Level;
8+
import org.openjdk.jmh.annotations.Scope;
9+
import org.openjdk.jmh.annotations.Setup;
10+
import org.openjdk.jmh.annotations.State;
11+
import org.openjdk.jmh.annotations.TearDown;
12+
import org.springframework.boot.SpringApplication;
13+
import org.springframework.context.ConfigurableApplicationContext;
14+
import org.springframework.util.FileSystemUtils;
15+
16+
import software.xdev.spring.data.eclipse.store.repository.EclipseStoreStorage;
17+
18+
19+
@State(Scope.Thread)
20+
public class SpringState
21+
{
22+
private ConfigurableApplicationContext context;
23+
private Path tempStorageDirectory;
24+
25+
@Setup(Level.Trial)
26+
public void doSetup() throws IOException
27+
{
28+
this.tempStorageDirectory = Files.createTempDirectory("tempstorage");
29+
this.context = SpringApplication.run(
30+
BenchmarkApplication.class,
31+
"--org.eclipse.store.storage-directory=" + this.tempStorageDirectory.toAbsolutePath());
32+
}
33+
34+
@Setup(Level.Invocation)
35+
public void doSetupData()
36+
{
37+
this.context.getBean(EclipseStoreStorage.class).clearData();
38+
}
39+
40+
@TearDown(Level.Invocation)
41+
public void doTearDownData()
42+
{
43+
this.context.getBean(EclipseStoreStorage.class).clearData();
44+
}
45+
46+
@TearDown(Level.Trial)
47+
public void doTearDown() throws IOException
48+
{
49+
SpringApplication.exit(this.context);
50+
this.context.close();
51+
this.context = null;
52+
FileSystemUtils.deleteRecursively(this.tempStorageDirectory);
53+
}
54+
55+
public <T> T getBean(final Class<T> classOfBeanToGet)
56+
{
57+
return this.context.getBean(classOfBeanToGet);
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.benchmark.benchmarks.simple.customer;
17+
18+
public class Customer
19+
{
20+
private final String firstName;
21+
private final String lastName;
22+
23+
public Customer(final String firstName, final String lastName)
24+
{
25+
this.firstName = firstName;
26+
this.lastName = lastName;
27+
}
28+
29+
@Override
30+
public String toString()
31+
{
32+
return "Customer{"
33+
+ "firstName='" + this.firstName + '\''
34+
+ ", lastName='" + this.lastName + '\''
35+
+ '}';
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package software.xdev.spring.data.eclipse.store.benchmark.benchmarks.simple.customer;
17+
18+
import org.springframework.data.repository.CrudRepository;
19+
20+
21+
public interface CustomerRepository extends CrudRepository<Customer, String>
22+
{
23+
}

0 commit comments

Comments
 (0)