3 ms·
The JIT is doing all the work, it appears. https://pastebin.com/TvJ8Y9cq https://pastebin.com/TvJ8Y9cq private static final byte[] _16 = new byte[16];
by iraqmtpizza 3y ago
The JIT is doing all the work, it appears.
https://pastebin.com/TvJ8Y9cq https://pastebin.com/TvJ8Y9cq
private static final byte[] _16 = new byte[16];
@Setup(Level.Trial)
public void setUp() {
final byte[] _eight = new byte[_16.length / 2];
new Random(System.currentTimeMillis() + System.nanoTime())
.nextBytes(_eight);
FastHex.encodeBytes(_eight, 0, _eight.length, _16, 0);
}
@Benchmark
@Fork(value = 1, warmups = 1)
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 1)
@Measurement(iterations = 3)
public void largeHexFast(Blackhole blackhole) {
blackhole.consume(FasterHex.decode(0, _16.length, i -> _16[i]));
}
- dzaima 3y agoA difference between this and the OP is that OP doesn't pass in a length, instead terminating on the first invalid character (which is the trailing null byte in the benchmark). Means that the array-out-of-bounds check can't be abused.
- iraqmtpizza 3y agoYeah, the methodologies aren't directly comparable (JMH is dark magic as well). For the record I used JMH 1.37