mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-06 07:21:32 +01:00
Add nbt case for tag bench
This commit is contained in:
parent
0bd266da23
commit
f2674b191a
@ -2,9 +2,12 @@ package net.minestom.jmh.tag;
|
||||
|
||||
import net.minestom.server.tag.Tag;
|
||||
import net.minestom.server.tag.TagHandler;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
||||
@ -22,13 +25,17 @@ public class TagReadBenchmark {
|
||||
TagHandler tagHandler;
|
||||
Tag<String> secondTag;
|
||||
|
||||
MutableNBTCompound compound;
|
||||
|
||||
@Setup
|
||||
public void setup() {
|
||||
// Tag benchmark
|
||||
this.tagHandler = TagHandler.newHandler();
|
||||
if (present) {
|
||||
tagHandler.setTag(TAG, "value");
|
||||
}
|
||||
if (present) tagHandler.setTag(TAG, "value");
|
||||
secondTag = Tag.String("key");
|
||||
// NBT benchmark
|
||||
this.compound = new MutableNBTCompound(new ConcurrentHashMap<>());
|
||||
if (present) compound.set("key", NBT.String("value"));
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@ -45,4 +52,9 @@ public class TagReadBenchmark {
|
||||
public void readNewTag(Blackhole blackhole) {
|
||||
blackhole.consume(tagHandler.getTag(Tag.String("key")));
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void readConstantTagFromCompound(Blackhole blackhole) {
|
||||
blackhole.consume(compound.getString("key"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user