• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

xxhashbench/H14-Nov-2019-

xxhsum/H14-Nov-2019-

.travis.ymlH A D14-Nov-2019110

README.mdH A D14-Nov-20192 KiB

go.modH A D14-Nov-201945

go.sumH A D14-Nov-20190

xxhash.goH A D14-Nov-20195.3 KiB

xxhash_amd64.goH A D14-Nov-2019220

xxhash_amd64.sH A D14-Nov-20193.5 KiB

xxhash_other.goH A D14-Nov-20191.5 KiB

xxhash_safe.goH A D14-Nov-2019392

xxhash_test.goH A D14-Nov-20194 KiB

xxhash_unsafe.goH A D14-Nov-20191.4 KiB

xxhash_unsafe_test.goH A D14-Nov-2019402

README.md

1# xxhash
2
3[![GoDoc](https://godoc.org/github.com/cespare/xxhash?status.svg)](https://godoc.org/github.com/cespare/xxhash)
4[![Build Status](https://travis-ci.org/cespare/xxhash.svg?branch=master)](https://travis-ci.org/cespare/xxhash)
5
6xxhash is a Go implementation of the 64-bit
7[xxHash](http://cyan4973.github.io/xxHash/) algorithm, XXH64. This is a
8high-quality hashing algorithm that is much faster than anything in the Go
9standard library.
10
11This package provides a straightforward API:
12
13```
14func Sum64(b []byte) uint64
15func Sum64String(s string) uint64
16type Digest struct{ ... }
17    func New() *Digest
18```
19
20The `Digest` type implements hash.Hash64. Its key methods are:
21
22```
23func (*Digest) Write([]byte) (int, error)
24func (*Digest) WriteString(string) (int, error)
25func (*Digest) Sum64() uint64
26```
27
28This implementation provides a fast pure-Go implementation and an even faster
29assembly implementation for amd64.
30
31## Compatibility
32
33This package is in a module and the latest code is in version 2 of the module.
34You need a version of Go with at least "minimal module compatibility" to use
35github.com/cespare/xxhash/v2:
36
37* 1.9.7+ for Go 1.9
38* 1.10.3+ for Go 1.10
39* Go 1.11 or later
40
41I recommend using the latest release of Go.
42
43## Benchmarks
44
45Here are some quick benchmarks comparing the pure-Go and assembly
46implementations of Sum64.
47
48| input size | purego | asm |
49| --- | --- | --- |
50| 5 B   |  979.66 MB/s |  1291.17 MB/s  |
51| 100 B | 7475.26 MB/s | 7973.40 MB/s  |
52| 4 KB  | 17573.46 MB/s | 17602.65 MB/s |
53| 10 MB | 17131.46 MB/s | 17142.16 MB/s |
54
55These numbers were generated on Ubuntu 18.04 with an Intel i7-8700K CPU using
56the following commands under Go 1.11.2:
57
58```
59$ go test -tags purego -benchtime 10s -bench '/xxhash,direct,bytes'
60$ go test -benchtime 10s -bench '/xxhash,direct,bytes'
61```
62
63## Projects using this package
64
65- [InfluxDB](https://github.com/influxdata/influxdb)
66- [Prometheus](https://github.com/prometheus/prometheus)
67- [FreeCache](https://github.com/coocood/freecache)
68