-
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.
Merge pull request #40 from avaerian/database-update
Merge all changes back with develop branch
- Loading branch information
Showing
189 changed files
with
7,883 additions
and
1,166 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
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
2 changes: 0 additions & 2 deletions
2
main/src/jmh/java/org/minerift/ether/benchmark/EvenOrOddBenchmarks.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
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
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
76 changes: 76 additions & 0 deletions
76
main/src/jmh/java/org/minerift/ether/benchmark/KeyDiffBenchmarks.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,76 @@ | ||
package org.minerift.ether.benchmark; | ||
|
||
import org.minerift.ether.database.sql.diff.DiffType; | ||
import org.minerift.ether.database.sql.diff.KeyDiff; | ||
import org.openjdk.jmh.annotations.*; | ||
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; | ||
import org.openjdk.jmh.runner.options.TimeValue; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Random; | ||
import java.util.Set; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.stream.Collectors; | ||
|
||
public class KeyDiffBenchmarks { | ||
|
||
private final static Random RANDOM = new Random(); | ||
|
||
public static void main(String[] args) throws RunnerException { | ||
|
||
Options options = new OptionsBuilder() | ||
.include(KeyDiffBenchmarks.class.getSimpleName()) | ||
.mode(Mode.AverageTime) | ||
.timeUnit(TimeUnit.NANOSECONDS) | ||
.warmupIterations(3) | ||
.warmupTime(TimeValue.seconds(5)) | ||
.threads(1) | ||
.measurementIterations(6) | ||
.measurementTime(TimeValue.seconds(2)) | ||
.forks(1) | ||
.shouldFailOnError(true) | ||
.shouldDoGC(true) | ||
.build(); | ||
|
||
new Runner(options).run(); | ||
} | ||
|
||
@State(Scope.Group) | ||
public static class KeyDiffState { | ||
Set<Integer> oldSet; | ||
Set<Integer> newSet; | ||
|
||
@Setup | ||
public void setup() { | ||
this.oldSet = randomNumSet(100, 0, 1000); | ||
this.newSet = randomNumSet(100, 0, 1000); | ||
} | ||
} | ||
|
||
private static Set<Integer> randomNumSet(int count, int minInclusive, int maxExclusive) { | ||
return RANDOM.ints(count, minInclusive, maxExclusive).boxed().collect(Collectors.toSet()); | ||
} | ||
|
||
@Group | ||
@Benchmark | ||
public KeyDiff.Diff<Integer>[] getDiffsBitsBenchmark(KeyDiffState state) { | ||
return KeyDiff.getDiffs(state.oldSet, state.newSet); | ||
} | ||
|
||
@Group | ||
@Benchmark | ||
public KeyDiff.Diff<Integer>[] getDiffsIfsBenchmark(KeyDiffState state) { | ||
return KeyDiff.getDiffsAlternate(state.oldSet, state.newSet); | ||
} | ||
|
||
@Group | ||
@Benchmark | ||
public Map<DiffType, List<Integer>> partitionDiffsBenchmark(KeyDiffState state) { | ||
return KeyDiff.partitionDiffs(state.oldSet, state.newSet); | ||
} | ||
|
||
} |
Oops, something went wrong.