Skip to content

Commit

Permalink
Merge pull request #40 from avaerian/database-update
Browse files Browse the repository at this point in the history
Merge all changes back with develop branch
  • Loading branch information
avaerian authored Jun 12, 2024
2 parents 3a444bd + f62093f commit 126d3f2
Show file tree
Hide file tree
Showing 189 changed files with 7,883 additions and 1,166 deletions.
9 changes: 7 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("com.github.johnrengelman.shadow") version("7.1.2") apply(false)
id("java")

// TODO: create a global constant for this plugin id
id("io.papermc.paperweight.userdev") version("1.5.4") apply(false)
}

Expand Down Expand Up @@ -36,13 +34,15 @@ allprojects {
dependencies {
include(project(":main"))
include(project(":v1_19_R1"))
include(dependency("xyz.jpenilla:reflection-remapper"))
}
}
}

// Paper-API dependency for submodules
subprojects {
repositories {
mavenCentral()
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
}

Expand All @@ -55,8 +55,13 @@ subprojects {
configure(subprojects.filter { listOf("v1_19_R1").contains(it.name) }) {
apply(plugin = "io.papermc.paperweight.userdev")

repositories {
mavenCentral()
}

dependencies {
implementation(project(":main"))
implementation("xyz.jpenilla:reflection-remapper:0.1.1")
}
}

Expand Down
14 changes: 14 additions & 0 deletions main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,23 @@ repositories {

dependencies {

// General libraries
implementation("com.google.guava:guava:31.1-jre")
implementation("com.google.code.gson:gson:2.10.1")
implementation("it.unimi.dsi:fastutil:8.5.6")
//implementation("org.jooq:joor-java-8:0.9.15")

// SQL stuffs
implementation("org.jooq:jooq:3.19.9")
implementation("com.zaxxer:HikariCP:5.0.1")

// Db drivers
implementation("org.xerial:sqlite-jdbc:3.43.0.0")
implementation("org.postgresql:postgresql:42.6.0")
implementation("com.h2database:h2:2.2.224")
implementation("com.mysql:mysql-connector-j:8.3.0")

// Plugin dependencies
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.14")

jmhImplementation("org.openjdk.jmh:jmh-core:1.36")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.minerift.ether.benchmark;

import org.minerift.ether.GridAlgorithm;
import org.minerift.ether.util.math.Vec2i;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.minerift.ether.benchmark;

import org.minerift.ether.GridAlgorithm;
import org.minerift.ether.util.math.Maths;
import org.minerift.ether.util.math.Vec2i;
import org.minerift.ether.math.GridAlgorithm;
import org.minerift.ether.math.Maths;
import org.minerift.ether.math.Vec2i;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
Expand Down Expand Up @@ -44,7 +44,6 @@ public static class ComputeTileState {
"(-31, 1)",
//"(-9, 104)"
})

public String tile;

}
Expand All @@ -69,7 +68,7 @@ public Vec2i computeTileBenchmark(ComputeTileIdState state) {

@Benchmark
public int computeTileIdBenchmark(ComputeTileState state) {
return GridAlgorithm.computeTileId(Maths.strToVec2i(state.tile).getValueOrDefault(() -> null));
return GridAlgorithm.computeTileId(Vec2i.fromString(state.tile));
}

@Benchmark
Expand All @@ -79,7 +78,7 @@ public int computeTileIdBenchmark_PREDETERMINED() {

@Benchmark
public Vec2i tile_parseFromStringBenchmark(ComputeTileState state) {
return Maths.strToVec2i(state.tile).getValueOrDefault(() -> null);
return Vec2i.fromString(state.tile);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.minerift.ether.GridAlgorithm;
import org.minerift.ether.math.GridAlgorithm;
import org.minerift.ether.island.*;
import org.minerift.ether.util.math.Vec2i;
import org.minerift.ether.math.Vec2i;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
Expand Down Expand Up @@ -103,6 +103,24 @@ public void setup() {
}
}

@State(Scope.Benchmark)
public static class IslandGridV2State {
IslandGridV2 grid;

@Setup
public void setup() {
this.grid = new IslandGridV2();
for(int i = 0; i < TILE_COUNT; i++) {
Island island = Island.builder()
.setTile(grid.getNextTile(), true)
.setDeleted(false)
.definePermissions(IslandRole.VISITOR)
.build();
grid.registerIsland(island);
}
}
}

@State(Scope.Benchmark)
public static class FastUtilMapState {

Expand Down Expand Up @@ -145,6 +163,11 @@ public Optional<Island> islandGrid_findIslandBenchmark(IslandGridState state) {
return state.grid.getIslandAt(TILE_TO_FIND);
}

@Benchmark
public Optional<Island> islandGridV2_findIslandBenchmark(IslandGridV2State state) {
return state.grid.getIslandAt(TILE_TO_FIND);
}

@Benchmark
public Optional<Island> hashMap_findIslandBenchmark(HashMapImplState state) {
return Optional.ofNullable(state.islands.get(TILE_TO_FIND));
Expand Down
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);
}

}
Loading

0 comments on commit 126d3f2

Please sign in to comment.