mirror of https://github.com/Minestom/Minestom.git
39 lines
1.0 KiB
Java
39 lines
1.0 KiB
Java
package net.minestom.server.tag;
|
|
|
|
import org.openjdk.jmh.annotations.*;
|
|
import org.openjdk.jmh.infra.Blackhole;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
@Warmup(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
|
@Measurement(iterations = 10, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
|
|
@Fork(3)
|
|
@BenchmarkMode(Mode.AverageTime)
|
|
@OutputTimeUnit(TimeUnit.NANOSECONDS)
|
|
@State(Scope.Benchmark)
|
|
public class TagReadPathBenchmark {
|
|
@Param({"0", "1", "2", "3"})
|
|
public int scope;
|
|
|
|
TagHandler tagHandler;
|
|
Tag<String> tag;
|
|
|
|
@Setup
|
|
public void setup() {
|
|
this.tagHandler = TagHandler.newHandler();
|
|
|
|
List<String> path = new ArrayList<>(scope);
|
|
for (int i = 0; i < scope; i++) path.add("key" + i);
|
|
this.tag = Tag.String("key").path(path.toArray(String[]::new));
|
|
|
|
tagHandler.setTag(tag, "value");
|
|
}
|
|
|
|
@Benchmark
|
|
public void read(Blackhole blackhole) {
|
|
blackhole.consume(tagHandler.getTag(tag));
|
|
}
|
|
}
|