Debian Codegraph @

/

debian rust-hamming-bitwise-fast 1.0.0-2debian librust-hamming-bitwise-fast-dev debian librust-hamming-bitwise-fast+default-dev debian librust-hamming-bitwise-fast-1-dev debian librust-hamming-bitwise-fast-1+default-dev debian librust-hamming-bitwise-fast-1.0-dev debian librust-hamming-bitwise-fast-1.0+default-dev debian librust-hamming-bitwise-fast-1.0.0-dev debian librust-hamming-bitwise-fast-1.0.0+default-dev debianjsonmakefilemarkdownrustshelltomlxml 23 files · 62 symbols
View dependency graph

Depends on

  • dh-cargo (dh-sequence-cargo)
  • cargo, debhelper-compat, libstd-rust-dev, rustc
README (full)

Hamming Bitwise Fast

A fast, zero-dependency implementation of bitwise Hamming Distance using a method amenable to auto-vectorization.

This started out as a benchmark of various bitwise Hamming distance implementations in Rust. However, after finding that a simple implementation that is amenable to auto-vectorization was comparable, if not faster, than other implementations, I decided to publish it as a crate.

Note: This is for comparing bit-vectors, not for comparing strings.

Usage

use hamming_bitwise_fast::hamming_bitwise_fast;

assert_eq!(hamming_bitwise_fast(&[0xFF; 1024], &[0xFF; 1024]), 0);
assert_eq!(hamming_bitwise_fast(&[0xFF; 1024], &[0x00; 1024]), 1024);

Benchmarks

This uses Criterion to benchmark various Hamming distance implementations:

  • The auto-vectorized implementation in this crate
  • A naive for-loop based implementation
  • A naive iterator based implementation
  • hamming hamming
  • hamming_rs hamming_rs
  • simsimd simsimd

Running the benchmark

cargo bench

Then open the target/criterion/report/index.html file in your browser to view the results.

Results

These were the results running on 3 different types of machines:

2023 MacBook Pro M2 Max

Benchmark results Benchmark results

Linode 2 CPU 4GB

Benchmark results Benchmark results

Fly.io 2 CPU 4GB

Benchmark results Benchmark results

License

This project is licensed under either of the following licenses, at your option:

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

dir benches/
dir debian/
dir results/
dir src/
file .cargo_vcs_info.json
file .gitignore
file Cargo.toml
file Cargo.toml.orig
file LICENSE-APACHE
file LICENSE-MIT
file README.md