Percentiles .java

net.minecraft.util.profiling.jfr.Percentiles (class): members: DEFAULT_INDEXES, evaluate. imports: Int2DoubleSortedMaps, Int2DoubleRBTreeMap, Quantiles.

net.minecraft.util.profiling.jfrclass35 linescommon1.3 KB

API Surface (3)

Map<Integer, Double> evaluate(final long[] dataset)
Map<Integer, Double> evaluate(final int[] dataset)
Map<Integer, Double> evaluate(final double[] dataset)

Fields & Constants (1)

DEFAULT_INDEXES

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

Percentiles.java35 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.profiling.jfr;
2
3
import com.google.common.math.Quantiles;
4
import com.google.common.math.Quantiles.ScaleAndIndexes;
5
import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
6
import it.unimi.dsi.fastutil.ints.Int2DoubleSortedMap;
7
import it.unimi.dsi.fastutil.ints.Int2DoubleSortedMaps;
8
import java.util.Comparator;
9
import java.util.Map;
10
import net.minecraft.util.Util;
11
12
public class Percentiles {
13
	public static final ScaleAndIndexes DEFAULT_INDEXES = Quantiles.scale(100).indexes(50, 75, 90, 99);
14
15
	private Percentiles() {
16
	}
17
18
	public static Map<Integer, Double> evaluate(final long[] dataset) {
19
		return dataset.length == 0 ? Map.of() : sorted(DEFAULT_INDEXES.compute(dataset));
20
	}
21
22
	public static Map<Integer, Double> evaluate(final int[] dataset) {
23
		return dataset.length == 0 ? Map.of() : sorted(DEFAULT_INDEXES.compute(dataset));
24
	}
25
26
	public static Map<Integer, Double> evaluate(final double[] dataset) {
27
		return dataset.length == 0 ? Map.of() : sorted(DEFAULT_INDEXES.compute(dataset));
28
	}
29
30
	private static Map<Integer, Double> sorted(final Map<Integer, Double> percentiles) {
31
		Int2DoubleSortedMap sorted = Util.make(new Int2DoubleRBTreeMap(Comparator.reverseOrder()), it -> it.putAll(percentiles));
32
		return Int2DoubleSortedMaps.unmodifiable(sorted);
33
	}
34
}
35

Decompiled Minecraft 26.3 source of Percentiles (net/minecraft/util/profiling/jfr/Percentiles.java) with Mojang official mappings, stored verbatim on the site.