mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 20:48:08 +01:00
Bench single thread hashmap
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
198618ba98
commit
07bebd6bc8
@ -5,6 +5,7 @@ import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
|
|||||||
import org.openjdk.jmh.annotations.*;
|
import org.openjdk.jmh.annotations.*;
|
||||||
import org.openjdk.jmh.infra.Blackhole;
|
import org.openjdk.jmh.infra.Blackhole;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ public class TagReadBenchmark {
|
|||||||
TagHandler tagHandler;
|
TagHandler tagHandler;
|
||||||
Tag<String> secondTag;
|
Tag<String> secondTag;
|
||||||
|
|
||||||
|
MutableNBTCompound concurrentCompound;
|
||||||
MutableNBTCompound compound;
|
MutableNBTCompound compound;
|
||||||
|
|
||||||
@Setup
|
@Setup
|
||||||
@ -31,8 +33,11 @@ public class TagReadBenchmark {
|
|||||||
this.tagHandler = TagHandler.newHandler();
|
this.tagHandler = TagHandler.newHandler();
|
||||||
if (present) tagHandler.setTag(TAG, "value");
|
if (present) tagHandler.setTag(TAG, "value");
|
||||||
secondTag = Tag.String("key");
|
secondTag = Tag.String("key");
|
||||||
// NBT benchmark
|
// Concurrent map benchmark
|
||||||
this.compound = new MutableNBTCompound(new ConcurrentHashMap<>());
|
this.concurrentCompound = new MutableNBTCompound(new ConcurrentHashMap<>());
|
||||||
|
if (present) concurrentCompound.set("key", NBT.String("value"));
|
||||||
|
// Hash map benchmark
|
||||||
|
this.compound = new MutableNBTCompound(new HashMap<>());
|
||||||
if (present) compound.set("key", NBT.String("value"));
|
if (present) compound.set("key", NBT.String("value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +57,12 @@ public class TagReadBenchmark {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
public void readConstantTagFromCompound(Blackhole blackhole) {
|
public void readConcurrentCompound(Blackhole blackhole) {
|
||||||
|
blackhole.consume(concurrentCompound.getString("key"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
public void readCompound(Blackhole blackhole) {
|
||||||
blackhole.consume(compound.getString("key"));
|
blackhole.consume(compound.getString("key"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user