Change Digest receiver name from x to d
8 files changed
tree: 511bd23f7c52872202c6a7bb0994f31368aa9652
  1. xxhsum/
  2. .travis.yml
  3. go.mod
  4. go.sum
  5. LICENSE.txt
  6. README.md
  7. rotate.go
  8. rotate19.go
  9. xxhash.go
  10. xxhash_amd64.go
  11. xxhash_amd64.s
  12. xxhash_amd64_test.go
  13. xxhash_other.go
  14. xxhash_safe.go
  15. xxhash_test.go
  16. xxhash_unsafe.go
README.md

xxhash

GoDoc Build Status

xxhash is a Go implementation of the 64-bit xxHash algorithm, XXH64. This is a high-quality hashing algorithm that is much faster than anything in the Go standard library.

The API is fairly small:

$ go doc github.com/cespare/xxhash
package xxhash // import "github.com/cespare/xxhash"

Package xxhash implements the 64-bit variant of xxHash (XXH64) as described
at http://cyan4973.github.io/xxHash/.

func Sum64(b []byte) uint64
func Sum64String(s string) uint64
type Digest struct{ ... }
    func New() *Digest

The type Digest implements hash.Hash64. Its key methods are:

func (*Digest) Write([]byte) (int, error)
func (*Digest) WriteString(string) (int, error)
func (*Digest) Sum64() uint64

This implementation provides a fast pure-Go implementation and an even faster assembly implementation for amd64.

Benchmarks

Here are some quick benchmarks comparing the pure-Go and assembly implementations of Sum64 against another popular Go XXH64 implementation, github.com/OneOfOne/xxhash:

input sizeOneOfOnecespare (purego)cespare
5 B416 MB/s720 MB/s872 MB/s
100 B3980 MB/s5013 MB/s5252 MB/s
4 KB12727 MB/s12999 MB/s13026 MB/s
10 MB9879 MB/s10775 MB/s10913 MB/s

These numbers were generated with:

$ go test -benchtime 10s -bench '/OneOfOne,'
$ go test -tags purego -benchtime 10s -bench '/xxhash,'
$ go test -benchtime 10s -bench '/xxhash,'

Projects using this package