xxhash

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2017 License: MIT Imports: 4 Imported by: 0

README

xxhash

GoDoc

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 very small, taking its cue from the other hashing packages in the standard library:

$ 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 New() hash.Hash64
func Sum64(b []byte) uint64
func Sum64String(s string) 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 size OneOfOne cespare (noasm) cespare
5 B 438.34 MB/s 596.40 MB/s 711.11 MB/s
100 B 3676.54 MB/s 4301.40 MB/s 4598.95 MB/s
4 KB 8128.64 MB/s 8840.83 MB/s 10549.72 MB/s
10 MB 7335.19 MB/s 7736.64 MB/s 9024.04 MB/s

Projects using this package

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() hash.Hash64

New creates a new hash.Hash64 that implements the 64-bit xxHash algorithm.

func Sum64

func Sum64(b []byte) uint64

Sum64 computes the 64-bit xxHash digest of b.

func Sum64String

func Sum64String(s string) uint64

Sum64String computes the 64-bit xxHash digest of s. It may be faster than Sum64([]byte(s)) by avoiding a copy.

TODO(caleb): Consider removing this if an optimization is ever added to make it unnecessary: https://golang.org/issue/2205.

TODO(caleb): We still have a function call; we could instead write Go/asm copies of Sum64 for strings to squeeze out a bit more speed.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL