mirror of
https://gitlab.uni-marburg.de/langbeid/powersort.git
synced 2025-01-21 19:50:35 +01:00
benchmark: JMH IntelliJ plugin
This commit is contained in:
parent
e6ab4f6656
commit
20bd4629b3
21
README.md
21
README.md
@ -39,7 +39,7 @@ This should include version >= 23, e.g.:
|
||||
|
||||
### Development Setup with nix
|
||||
|
||||
The provided [shell.nix](shell.nix) file can be used to set up a development environment with IntelliJ. The only prerequisite is to have a working `nix` installation for which there are multiple possibilities, e.g:
|
||||
The provided [./shell.nix](./shell.nix) file can be used to set up a development environment with IntelliJ. The only prerequisite is to have a working `nix` installation for which there are multiple possibilities, e.g:
|
||||
|
||||
```shell
|
||||
# https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#determinate-nix-installer
|
||||
@ -90,26 +90,37 @@ There are two different benchmarks. One is based on the JMH benchmark framework,
|
||||
|
||||
### Custom
|
||||
|
||||
Run custom benchmark:
|
||||
Run Custom Benchmark (CGM) with
|
||||
|
||||
- Custom Generated Lists (CGL):
|
||||
|
||||
```shell
|
||||
./gradlew runCbmCgl
|
||||
```
|
||||
|
||||
- Powersort competition lists:
|
||||
|
||||
```shell
|
||||
./gradlew runCbmCompetition
|
||||
```
|
||||
|
||||
### JMH
|
||||
|
||||
Run JMH benchmark:
|
||||
#### Run JMH with CGL and Powersort competition lists
|
||||
|
||||
```shell
|
||||
./gradlew jmh
|
||||
```
|
||||
|
||||
IntelliJ plugin:
|
||||
- To benchmark only one of the different list collections, see `jmh { excludes }` at the bottom of [./app/build.gradle.kts](./app/build.gradle.kts).
|
||||
|
||||
#### IntelliJ plugin
|
||||
|
||||
The [JMH Java Microbenchmark Harness](https://plugins.jetbrains.com/plugin/7529-jmh-java-microbenchmark-harness) plugin allows running benchmarks from within the IDE in a similar way as JUnit test cases. This can be used for development but yields less accurate results.
|
||||
|
||||
Further notes:
|
||||
![intellij-jmh.png](intellij-jmh.png)
|
||||
|
||||
#### Further notes
|
||||
|
||||
- JHM: https://github.com/openjdk/jmh?tab=readme-ov-file#other-build-systems
|
||||
- We use the JMH Gradle plugin: https://github.com/melix/jmh-gradle-plugin
|
||||
|
@ -83,6 +83,8 @@ jmh {
|
||||
forceGC = true
|
||||
|
||||
excludes = listOf(
|
||||
"de.uni_marburg.powersort.benchmark.JmhBase.benchmark",
|
||||
// To skip JmhCgl or JmhCompetition, uncomment it below.
|
||||
// "de.uni_marburg.powersort.benchmark.JmhCgl.benchmark",
|
||||
// "de.uni_marburg.powersort.benchmark.JmhCompetition.benchmark",
|
||||
)
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import de.uni_marburg.powersort.data.DataEnum;
|
||||
import de.uni_marburg.powersort.data.ObjectSupplier;
|
||||
import de.uni_marburg.powersort.sort.SortEnum;
|
||||
import de.uni_marburg.powersort.sort.SortImpl;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||
import org.openjdk.jmh.annotations.Fork;
|
||||
import org.openjdk.jmh.annotations.Level;
|
||||
@ -75,9 +74,4 @@ public class JmhBase {
|
||||
// This way, all iterations sort the same input.
|
||||
workingCopy = data.getCopy();
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void benchmark() {
|
||||
sortImpl.sort(workingCopy);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package de.uni_marburg.powersort.benchmark;
|
||||
import de.uni_marburg.powersort.data.CglEnum;
|
||||
import de.uni_marburg.powersort.data.DataEnum;
|
||||
import de.uni_marburg.powersort.sort.SortEnum;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.Param;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
@ -28,4 +29,12 @@ public class JmhCgl extends JmhBase {
|
||||
SortEnum getSortEnum(){
|
||||
return sortEnum;
|
||||
}
|
||||
|
||||
// We could move this method up to JmhBase to avoid redundancy in the subclasses.
|
||||
// But this would remove the run button of the IntelliJ plugin "JMH Java Microbenchmark Harness".
|
||||
// Furthermore, with this approach we don't need to exclude JmhBase as it has no benchmark methods.
|
||||
@Benchmark
|
||||
public void benchmark() {
|
||||
sortImpl.sort(workingCopy);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package de.uni_marburg.powersort.benchmark;
|
||||
import de.uni_marburg.powersort.data.CompetitionEnum;
|
||||
import de.uni_marburg.powersort.data.DataEnum;
|
||||
import de.uni_marburg.powersort.sort.SortEnum;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.Param;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
@ -28,4 +29,9 @@ public class JmhCompetition extends JmhBase {
|
||||
SortEnum getSortEnum(){
|
||||
return sortEnum;
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void benchmark() {
|
||||
sortImpl.sort(workingCopy);
|
||||
}
|
||||
}
|
||||
|
BIN
intellij-jmh.png
Normal file
BIN
intellij-jmh.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Loading…
x
Reference in New Issue
Block a user