ChibiHashGo is a simple, fast 64-bit hash function implemented in Go. It is designed for performance and ease of use in applications where efficient hashing is required.
- Minimal dependencies
- Optimized for performance
- Supports inputs of varying sizes (small keys to large datasets)
- Includes comprehensive benchmarks and GitHub Actions integration for CI
To install ChibiHashGo, use go get
:
go get github.com/yourusername/ChibiHashGo
Import the package and use ChibiHash64
to compute hash values.
Example:
package main
import (
"fmt"
"github.com/eranchetz/ChibiHashGo"
)
func main() {
key := []byte("example")
seed := uint64(42)
hash := chibihash.ChibiHash64(key, len(key), seed)
fmt.Printf("Hash: %x\n", hash)
}
- key: The data to hash as a byte slice.
- length: The length of the data.
- seed: A 64-bit seed value for hashing.
- Returns: A 64-bit unsigned integer hash.
The following benchmarks demonstrate the performance of ChibiHash64
for varying input sizes. These results were obtained using go test -bench=. -benchmem
.
Test Case | ns/op | B/op | allocs/op |
---|---|---|---|
5 Bytes | 4.215 | 0 | 0 |
100 Bytes | 5.155 | 0 | 0 |
4 KB | 44.78 | 0 | 0 |
10 MB | 888191 | 0 | 0 |
The function performs efficiently with no memory allocations (allocs/op = 0
) across all test cases, ensuring minimal overhead.
GitHub Actions is set up to automatically run tests and benchmarks for every push or pull request.
The workflow file is located at .github/workflows/go.yml
and includes:
- Installing dependencies (
go mod tidy
) - Running tests (
go test ./... -v
) - Running benchmarks (
go test -bench=. -benchmem
)
To test the module locally:
go test ./... -v
To run benchmarks:
go test -bench=. -benchmem
Contributions are welcome! Fork the repository, make your changes, and submit a pull request. Ensure all tests pass and benchmarks are updated before submitting.
This project is licensed under the Unlicense.