xxh3

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: BSD-2-Clause Imports: 5 Imported by: 160

README

XXH3

GoDoc Sourcegraph Go Report Card

This package is a port of the xxh3 library to Go.

Upstream has fixed the output as of v0.8.0, and this package matches that.


Benchmarks

Run on my i7-8850H CPU @ 2.60GHz

Small Sizes

Bytes Rate
0 0.74 ns/op
1-3 4.19 ns/op (0.24 GB/s - 0.71 GB/s)
4-8 4.16 ns/op (0.97 GB/s - 1.98 GB/s)
9-16 4.46 ns/op (2.02 GB/s - 3.58 GB/s)
17-32 6.22 ns/op (2.76 GB/s - 5.15 GB/s)
33-64 8.00 ns/op (4.13 GB/s - 8.13 GB/s)
65-96 11.0 ns/op (5.91 GB/s - 8.84 GB/s)
97-128 12.8 ns/op (7.68 GB/s - 10.0 GB/s)

Large Sizes

Bytes Rate SSE2 Rate AVX2 Rate
129 13.6 ns/op (9.45 GB/s)
240 23.8 ns/op (10.1 GB/s)
241 40.5 ns/op (5.97 GB/s) 23.3 ns/op (10.4 GB/s) 20.1 ns/op (12.0 GB/s)
512 69.8 ns/op (7.34 GB/s) 30.4 ns/op (16.9 GB/s) 24.7 ns/op (20.7 GB/s)
1024 132 ns/op (7.77 GB/s) 48.9 ns/op (20.9 GB/s) 37.7 ns/op (27.2 GB/s)
100KB 13.0 us/op (7.88 GB/s) 4.05 us/op (25.3 GB/s) 2.31 us/op (44.3 GB/s)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(b []byte) uint64

Hash returns the hash of the byte slice.

func HashSeed added in v1.0.0

func HashSeed(b []byte, seed uint64) uint64

HashSeed returns the hash of the byte slice with given seed.

func HashString

func HashString(s string) uint64

Hash returns the hash of the string slice.

func HashStringSeed added in v1.0.0

func HashStringSeed(s string, seed uint64) uint64

HashStringSeed returns the hash of the string slice with given seed.

Types

type Hasher added in v0.13.0

type Hasher struct {
	// contains filtered or unexported fields
}

Hasher implements the hash.Hash interface

func New added in v0.13.0

func New() *Hasher

New returns a new Hasher that implements the hash.Hash interface.

func NewSeed added in v1.0.0

func NewSeed(seed uint64) *Hasher

NewSeed returns a new Hasher that implements the hash.Hash interface.

func (*Hasher) BlockSize added in v0.13.0

func (h *Hasher) BlockSize() int

BlockSize returns the hash's underlying block size. The Write method will accept any amount of data, but it may operate more efficiently if all writes are a multiple of the block size.

func (*Hasher) Reset added in v0.13.0

func (h *Hasher) Reset()

Reset resets the Hash to its initial state.

func (*Hasher) Size added in v0.13.0

func (h *Hasher) Size() int

Size returns the number of bytes Sum will return.

func (*Hasher) Sum added in v0.13.0

func (h *Hasher) Sum(b []byte) []byte

Sum appends the current hash to b and returns the resulting slice. It does not change the underlying hash state.

func (*Hasher) Sum128 added in v0.13.0

func (h *Hasher) Sum128() Uint128

Sum128 returns the 128-bit hash of the written data.

func (*Hasher) Sum64 added in v0.13.0

func (h *Hasher) Sum64() uint64

Sum64 returns the 64-bit hash of the written data.

func (*Hasher) Write added in v0.13.0

func (h *Hasher) Write(buf []byte) (int, error)

Write adds more data to the running hash. It never returns an error.

func (*Hasher) WriteString added in v0.13.0

func (h *Hasher) WriteString(buf string) (int, error)

WriteString adds more data to the running hash. It never returns an error.

type Uint128 added in v0.11.0

type Uint128 struct {
	Hi, Lo uint64
}

Uint128 is a 128 bit value. The actual value can be thought of as u.Hi<<64 | u.Lo.

func Hash128 added in v0.9.0

func Hash128(b []byte) Uint128

Hash128 returns the 128-bit hash of the byte slice.

func Hash128Seed added in v1.0.0

func Hash128Seed(b []byte, seed uint64) Uint128

Hash128Seed returns the 128-bit hash of the byte slice.

func HashString128 added in v0.9.0

func HashString128(s string) Uint128

HashString128 returns the 128-bit hash of the string slice.

func HashString128Seed added in v1.0.0

func HashString128Seed(s string, seed uint64) Uint128

HashString128Seed returns the 128-bit hash of the string slice.

func (Uint128) Bytes added in v0.13.0

func (u Uint128) Bytes() [16]byte

Bytes returns the uint128 as an array of bytes in canonical form (big-endian encoded).

Directories

Path Synopsis
avo module
internal

Jump to

Keyboard shortcuts

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