mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 20:18:10 +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.infra.Blackhole;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -23,6 +24,7 @@ public class TagReadBenchmark {
|
||||
TagHandler tagHandler;
|
||||
Tag<String> secondTag;
|
||||
|
||||
MutableNBTCompound concurrentCompound;
|
||||
MutableNBTCompound compound;
|
||||
|
||||
@Setup
|
||||
@ -31,8 +33,11 @@ public class TagReadBenchmark {
|
||||
this.tagHandler = TagHandler.newHandler();
|
||||
if (present) tagHandler.setTag(TAG, "value");
|
||||
secondTag = Tag.String("key");
|
||||
// NBT benchmark
|
||||
this.compound = new MutableNBTCompound(new ConcurrentHashMap<>());
|
||||
// Concurrent map benchmark
|
||||
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"));
|
||||
}
|
||||
|
||||
@ -52,7 +57,12 @@ public class TagReadBenchmark {
|
||||
}
|
||||
|
||||
@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"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user