Debian Codegraph @

README.md

raw symbols SCIP
1
2 # wyhash
3 [![GoDoc](https://godoc.org/github.com/zeebo/wyhash?status.svg)](https://godoc.org/github.com/zeebo/wyhash)
4 [![Sourcegraph](https://sourcegraph.com/github.com/zeebo/wyhash/-/badge.svg)](https://sourcegraph.com/github.com/zeebo/wyhash?badge)
5 [![Go Report Card](https://goreportcard.com/badge/github.com/zeebo/wyhash)](https://goreportcard.com/report/github.com/zeebo/wyhash)
6
7 This package is a port of the [wyhash](https://github.com/wangyi-fudan/wyhash) library v3 to Go.
8
9 ---
10
11 # Hash Benchmarks
12
13 Run on my `i7-6700K CPU @ 4.00GHz`
14
15 | Bytes | Rate |
16 |-----------|--------------------------------------|
17 |` 0 ` |` 0.49 ns/op ` |
18 |` 1-3 ` |` 3.46 ns/op (0.29 GB/s - 0.88 GB/s) `|
19 |` 4-8 ` |` 3.40 ns/op (1.17 GB/s - 2.38 GB/s) `|
20 |` 9-16 ` |` 3.64 ns/op (2.47 GB/s - 4.39 GB/s) `|
21 |` 17-32 ` |` 4.63 ns/op (3.68 GB/s - 6.11 GB/s) `|
22 |` 33-64 ` |` 7.51 ns/op (4.40 GB/s - 7.98 GB/s) `|
23 |` 65-96 ` |` 9.22 ns/op (7.05 GB/s - 9.98 GB/s) `|
24 |` 97-128 ` |` 10.7 ns/op (9.03 GB/s - 11.3 GB/s) `|
25 |` 240 ` |` 17.5 ns/op (13.7 GB/s) ` |
26 |` 512 ` |` 37.3 ns/op (13.7 GB/s) ` |
27 |` 1024 ` |` 69.0 ns/op (14.8 GB/s) ` |
28 |` 100KB ` |` 6059 ns/op (16.9 GB/s) ` |
29
30 # RNG Benchmarks
31
32 | Method | Speed |
33 |-------------------|---------------|
34 |` Uint64 ` |` 1.31 ns/op ` |
35 |` Uint64n(large) ` |` 12.7 ns/op ` |
36 |` Uint64n(med) ` |` 2.40 ns/op ` |
37 |` Uint64n(small) ` |` 2.43 ns/op ` |
38 |` Float64 ` |` 2.17 ns/op ` |
39
40 # Usage
41
42 #### func Float64
43
44 ```go
45 func Float64() float64
46 ```
47 Float64 returns a float64 uniformly in [0, 1). Safe for concurrent callers.
48
49 #### func Hash
50
51 ```go
52 func Hash(data []byte, seed uint64) uint64
53 ```
54 Hash returns a 64bit digest of the data with different ones for every seed.
55
56 #### func HashString
57
58 ```go
59 func HashString(data string, seed uint64) uint64
60 ```
61 HashString returns a 64bit digest of the data with different ones for every
62 seed.
63
64 #### func Int
65
66 ```go
67 func Int() int
68 ```
69 Int returns a random int. Safe for concurrent callers.
70
71 #### func Intn
72
73 ```go
74 func Intn(n int) int
75 ```
76 Intn returns a int uniformly in [0, n). Safe for concurrent callers.
77
78 #### func Uint64
79
80 ```go
81 func Uint64() uint64
82 ```
83 Uint64 returns a random uint64. Safe for concurrent callers.
84
85 #### func Uint64n
86
87 ```go
88 func Uint64n(n uint64) uint64
89 ```
90 Uint64n returns a uint64 uniformly in [0, n). Safe for concurrent callers.
91
92 #### type RNG
93
94 ```go
95 type RNG uint64
96 ```
97
98 RNG is a random number generator. The zero value is valid.
99
100 #### func (*RNG) Float64
101
102 ```go
103 func (r *RNG) Float64() (v float64)
104 ```
105 Float64 returns a float64 uniformly in [0, 1). Not safe for concurrent callers.
106
107 #### func (*RNG) Int
108
109 ```go
110 func (r *RNG) Int() int
111 ```
112 Int returns a random int. Not safe for concurrent callers.
113
114 #### func (*RNG) Intn
115
116 ```go
117 func (r *RNG) Intn(n int) int
118 ```
119 Intn returns an int uniformly in [0, n). Not safe for concurrent callers.
120
121 #### func (*RNG) Uint64
122
123 ```go
124 func (r *RNG) Uint64() uint64
125 ```
126 Uint64 returns a random uint64. Not safe for concurrent callers.
127
128 #### func (*RNG) Uint64n
129
130 ```go
131 func (r *RNG) Uint64n(n uint64) uint64
132 ```
133 Uint64n returns a uint64 uniformly in [0, n). Not safe for concurrent callers.