Files
Fangrui Song 525fab579d [ADT] Decouple xxhash.h from ADT. NFC (#196774)
Move xxHash64, xxh3_64bits, and xxh3_128bits ArrayRef/StringRef
overloads from llvm/Support/xxhash.h to inline overloads in
llvm/ADT/ArrayRef.h and llvm/ADT/StringRef.h, so xxhash.h has no ADT
dependencies.

This is prerequisite for using xxh3 as the combine_bytes backend in
llvm/ADT/Hashing.h (#194567), which would otherwise reintroduce a header
dependency cycle.

FoldingSet.h and StableHashing.h adjust to call the new
pointer-and-length entry point.
2026-05-10 04:24:49 +00:00

31 lines
758 B
C++

#include "llvm/Support/xxhash.h"
#include "benchmark/benchmark.h"
#include "llvm/ADT/ArrayRef.h"
#include <memory>
static uint32_t xorshift(uint32_t State) {
State ^= State << 13;
State ^= State >> 17;
State ^= State << 5;
return State;
}
static void BM_xxh3_64bits(benchmark::State &State) {
std::unique_ptr<uint32_t[]> Data(new uint32_t[State.range(0) / 4]);
uint32_t Prev = 0xcafebabe;
for (int64_t I = 0; I < State.range(0) / 4; I++)
Data[I] = Prev = xorshift(Prev);
llvm::ArrayRef DataRef =
llvm::ArrayRef(reinterpret_cast<uint8_t *>(Data.get()), State.range(0));
for (auto _ : State)
llvm::xxh3_64bits(DataRef);
}
BENCHMARK(BM_xxh3_64bits)->Arg(32)->Arg(512)->Arg(64 * 1024)->Arg(1024 * 1024);
BENCHMARK_MAIN();