You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.1 KiB

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