Files
openide/platform/util/immutable-key-value-store/benchmark/test/HashBenchmark.java
Daniil Ovchinnikov 5309733f3c move intellij.platform.util.immutableKeyValueStore.benchmark content to test sources
GitOrigin-RevId: adad0fe575ce662fa469d42cf25408ecd96fb350
2024-02-28 17:05:49 +00:00

35 lines
908 B
Java

// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.util.immutableKeyValueStore.benchmark;
import com.intellij.util.lang.Murmur3_32Hash;
import org.openjdk.jmh.annotations.*;
import java.util.Random;
import java.util.concurrent.TimeUnit;
/*
Benchmark Mode Cnt Score Error Units
HashBenchmark.murmur3 avgt 10 2379.621 ± 9.704 ns/op
HashBenchmark.xxh3 avgt 10 585.030 ± 0.691 ns/op
*/
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Measurement(iterations = 5, time = 4)
@Fork(2)
public class HashBenchmark {
private static final byte[] data;
static {
data = new byte[5_000];
new Random(42).nextBytes(data);
}
@Benchmark
public int murmur3() {
return Murmur3_32Hash.MURMUR3_32.hashBytes(data, 0, data.length);
}
}