wyhash

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: MIT Imports: 2 Imported by: 1

README

wyhash

A pure-Go wyhash implementation.

How to use

import (
	"flag"
	"fmt"
	"io"
	"os"

	"github.com/orisano/wyhash"
)

func main() {
	seed := flag.Int("s", 0, "seed value")
	flag.Parse()

	h := wyhash.New(uint64(*seed))
	io.Copy(h, os.Stdin)
	fmt.Printf("%x\n", h.Sum64())
}

Benchmark

$ go test -bench . crypto/sha1
goos: darwin
goarch: amd64
pkg: crypto/sha1
BenchmarkHash8Bytes-4     	10000000	       175 ns/op	  45.48 MB/s
BenchmarkHash320Bytes-4   	 2000000	       700 ns/op	 456.49 MB/s
BenchmarkHash1K-4         	 1000000	      1377 ns/op	 743.30 MB/s
BenchmarkHash8K-4         	  200000	      9047 ns/op	 905.41 MB/s
PASS
ok  	crypto/sha1	7.375s
$ go test -bench . github.com/orisano/wyhash
goos: darwin
goarch: amd64
pkg: github.com/orisano/wyhash
BenchmarkHash8Bytes-4     	50000000	        24.1 ns/op	 332.51 MB/s
BenchmarkHash320Bytes-4   	20000000	        78.7 ns/op	4066.50 MB/s
BenchmarkHash1K-4         	10000000	       223 ns/op	4582.73 MB/s
BenchmarkHash8K-4         	 1000000	      1633 ns/op	5015.29 MB/s
PASS
ok  	github.com/orisano/wyhash	7.017s

Author

Nao YONASHIRO (@orisano)

License

MIT

Reference

Documentation

Overview

Package wyhash implements the wyhash hash algorithm as defined in github.com/wangyi-fudan/wyhash

Index

Constants

View Source
const BlockSize = 32

The blocksize of wyhash in bytes.

View Source
const Size = 8

The size of a wyhash checksum in bytes.

Variables

This section is empty.

Functions

func New

func New(seed uint64) hash.Hash64

New returns a new hash.Hash64 computing the wyhash checksum.

func Sum64 added in v1.1.0

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

Sum64 returns the wyhash checksum of the b

Types

type Rand

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

func (*Rand) Int63

func (r *Rand) Int63() int64

func (*Rand) Seed

func (r *Rand) Seed(seed int64)

func (*Rand) Uint64

func (r *Rand) Uint64() uint64

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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