xxhash

package module
v0.0.0-...-51cb426 Latest Latest
Warning

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

Go to latest
Published: May 24, 2014 License: MIT Imports: 3 Imported by: 0

README

xxHash

Go package for a fast non-cryptographic hash function. Referenced from here. It's significantly faster than the standard library's FNV hash, mostly because of the unsafe package. It satisfies the hash.Hash32 interface but a quicker checksum function is provided as well.

Installation
go get github.com/asadmshah/xxhash
Usage

Using it through the hash.Hash interface:

var seed uint32 = 1
h := xxhash.New(seed)
h.Write([]byte("a"))
h.Sum(nil) // Returns []byte{0x0b, 0x2c, 0xb7, 0x92}

Or to quickly hash something:

var seed uint32 = 1
xxhash.Checksum([]byte("a"), seed) // Returns []byte{0x0b, 0x2c, 0xb7, 0x92}
Benchmarks

Benchmarks are run using 1024 bytes.

BenchmarkHashing	 5000000	       369 ns/op	2774.14 MB/s	      24 B/op	       2 allocs/op
BenchmarkChecksum	10000000	       183 ns/op	5586.22 MB/s	       0 B/op	       0 allocs/op
BenchmarkFNVHash	 1000000	      1353 ns/op	 756.68 MB/s	       8 B/op	       1 allocs/op

Documentation

Overview

package xxhash implements a fast non-cryptographic hashing algorithm ported from https://code.google.com/p/xxhash/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checksum

func Checksum(data []byte, seed uint32) uint32

Checksum returns the xxHash checksum of data.

func New

func New(seed uint32) hash.Hash32

New returns a new 32-bit xxHash hash.Hash initialized with seed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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