NikoMalik/wyhash
wyhash implementation in zig
🚀 Overview
Wyhash is a fast, high-quality, portable non-cryptographic hash function known for its exceptional speed and randomness quality. This repository provides a native Zig implementation of Wyhash.Project is also open for people to add to and improve. Please check the issues to view requested features
Why Wyhash?
const wyhash = @import("wyhash");
const std = @import("std");
pub fn main() !void {
const r: u64 = 0x001020120;
const res = wyhash._whash("🔥Hello World!", r);
std.debug.print("wyhash(\"🔥Hello World!\", {}) = {}\n", .{ r, res });
}
Add this to your build.zig.zon
.dependencies = .{
.wyhash = .{
.url = "https://github.com/NikoMalik/wyhash/archive/refs/heads/main.tar.gz",
//the correct hash will be suggested by zig
}
}
And add this to you build.zig
const wyhash = b.dependency("wyhash", .{
.target = target,
.optimize = optimize,
});
exe_mod.addImport("wyhash", wyhash.module("wyhash"));
You can then import the library into your code like this
const wyhash = @import("wyhash")
git clone https://github.com/NikoMalik/wyhash.git
mv wyhash /path/to/your/project/directory
Wyhash is one of the fastest hash functions available. Benchmarks against MurmurHash3, XXHash, and CityHash show superior performance in most cases.
Original Wyhash: Wang Yi