-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bd8227
commit 9202b4b
Showing
16 changed files
with
504 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="module" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>collections-benchmarking</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
4 changes: 4 additions & 0 deletions
4
collections-benchmarking/.settings/org.eclipse.core.resources.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eclipse.preferences.version=1 | ||
encoding//src/main/java=UTF-8 | ||
encoding//src/test/java=UTF-8 | ||
encoding/<project>=UTF-8 |
16 changes: 16 additions & 0 deletions
16
collections-benchmarking/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=17 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | ||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning | ||
org.eclipse.jdt.core.compiler.release=enabled | ||
org.eclipse.jdt.core.compiler.source=17 |
4 changes: 4 additions & 0 deletions
4
collections-benchmarking/.settings/org.eclipse.m2e.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.example</groupId> | ||
<artifactId>collections-benchmarking</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>JMH benchmark sample: Java</name> | ||
|
||
<prerequisites> | ||
<maven>3.0</maven> | ||
</prerequisites> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.collections</groupId> | ||
<artifactId>eclipse-collections</artifactId> | ||
<version>9.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-core</artifactId> | ||
<version>${jmh.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-generator-annprocess</artifactId> | ||
<version>${jmh.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<jmh.version>1.19</jmh.version> | ||
<javac.target>1.8</javac.target> | ||
<uberjar.name>benchmarks</uberjar.name> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<compilerVersion>${javac.target}</compilerVersion> | ||
<source>${javac.target}</source> | ||
<target>${javac.target}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.2</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<finalName>${uberjar.name}</finalName> | ||
<transformers> | ||
<transformer | ||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>org.openjdk.jmh.Main</mainClass> | ||
</transformer> | ||
</transformers> | ||
<filters> | ||
<filter> | ||
<artifact>*:*</artifact> | ||
<excludes> | ||
<exclude>META-INF/*.SF</exclude> | ||
<exclude>META-INF/*.DSA</exclude> | ||
<exclude>META-INF/*.RSA</exclude> | ||
</excludes> | ||
</filter> | ||
</filters> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>2.5</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<version>2.5.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.4</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>2.9.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>2.6</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<version>3.3</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.2.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.17</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
|
||
</project> |
127 changes: 127 additions & 0 deletions
127
collections-benchmarking/src/main/java/com/example/benchmarks/ListBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package com.example.benchmarks; | ||
|
||
import java.util.ArrayDeque; | ||
import java.util.ArrayList; | ||
import java.util.Deque; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.eclipse.collections.impl.list.mutable.FastList; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
|
||
public class ListBenchmark { | ||
|
||
private static final int DATA_SIZE = 100_000; | ||
|
||
@Benchmark | ||
public void addTail_FastList() { | ||
List<Integer> list = new FastList<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(i); | ||
} | ||
|
||
@Benchmark | ||
public void addTail_FastList_FullCapacity() { | ||
List<Integer> list = new FastList<>(DATA_SIZE); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(i); | ||
} | ||
|
||
@Benchmark | ||
public void addHead_FastList() { | ||
List<Integer> list = new FastList<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(0,i); | ||
} | ||
|
||
@Benchmark | ||
public void addHead_FastList_FullCapacity() { | ||
List<Integer> list = new FastList<>(DATA_SIZE); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(0,i); | ||
} | ||
|
||
@Benchmark | ||
public void addTail_ArrayList() { | ||
List<Integer> list = new ArrayList<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(i); | ||
} | ||
|
||
@Benchmark | ||
public void addTail_ArrayList_fullCapacity() { | ||
List<Integer> list = new ArrayList<>(DATA_SIZE); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(i); | ||
} | ||
|
||
@Benchmark | ||
public void addTail_ArrayDeque() { | ||
Deque<Integer> list = new ArrayDeque<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.addLast(i); | ||
} | ||
|
||
@Benchmark | ||
public void addTail_ArrayDeque_fullCapacity() { | ||
Deque<Integer> list = new ArrayDeque<>(DATA_SIZE); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.addLast(i); | ||
} | ||
|
||
@Benchmark() | ||
public void addHead_ArrayList() { | ||
List<Integer> list = new ArrayList<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(0, i); | ||
} | ||
|
||
@Benchmark() | ||
public void addHead_ArrayList_fullCapacity() { | ||
List<Integer> list = new ArrayList<>(DATA_SIZE); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(0, i); | ||
} | ||
|
||
@Benchmark | ||
public void addHead_ArrayDeque() { | ||
Deque<Integer> list = new ArrayDeque<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.addFirst(i); | ||
} | ||
|
||
@Benchmark | ||
public void addHead_ArrayDeque_fullCapacity() { | ||
Deque<Integer> list = new ArrayDeque<>(DATA_SIZE); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.addFirst(i); | ||
} | ||
|
||
@Benchmark | ||
public void addTail_LinkedList() { | ||
List<Integer> list = new LinkedList<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(i); | ||
} | ||
|
||
@Benchmark | ||
public void addHead_LinkedList() { | ||
List<Integer> list = new LinkedList<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
list.add(0, i); | ||
} | ||
|
||
public static void main(String[] args) throws RunnerException { | ||
Options opt = new OptionsBuilder() | ||
.include(ListBenchmark.class.getSimpleName()) | ||
.warmupIterations(5) | ||
.measurementIterations(5) | ||
.forks(1).build(); | ||
|
||
new Runner(opt).run(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
collections-benchmarking/src/main/java/com/example/benchmarks/SetBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.example.benchmarks; | ||
|
||
import java.util.HashSet; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.RunnerException; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
|
||
public class SetBenchmark { | ||
|
||
private static final int DATA_SIZE= 250_000; | ||
|
||
@Benchmark | ||
public void add_HashSet() { | ||
Set<Integer> set = new HashSet<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
set.add(i); | ||
} | ||
|
||
@Benchmark | ||
public void add_LinkedHashSet() { | ||
Set<Integer> set = new LinkedHashSet<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
set.add(i); | ||
} | ||
|
||
@Benchmark | ||
public void add_TreeHashSet() { | ||
Set<Integer> set = new TreeSet<>(); | ||
for (int i = 0; i < DATA_SIZE; ++i) | ||
set.add(i); | ||
} | ||
|
||
public static void main(String[] args) throws RunnerException { | ||
Options opt = new OptionsBuilder() | ||
.include(SetBenchmark.class.getSimpleName()) | ||
.warmupIterations(5) | ||
.measurementIterations(10) | ||
.forks(1) | ||
.build(); | ||
|
||
new Runner(opt).run(); | ||
} | ||
} |
Oops, something went wrong.