forked from cerc-io/plugeth
9effd64290
* core, eth, trie: bloom filter for trie node dedup during fast sync * eth/downloader, trie: address review comments * core, ethdb, trie: restart fast-sync bloom construction now and again * eth/downloader: initialize fast sync bloom on startup * eth: reenable eth/62 until we properly remove it |
||
---|---|---|
.. | ||
doc.go | ||
hamming.go | ||
MIT-LICENSE.txt | ||
popcnt_amd64.go | ||
popcnt_amd64.s | ||
popcount_slices_amd64.go | ||
popcount_slices_amd64.s | ||
popcount_slices.go | ||
popcount.go | ||
README.md | ||
slices_of_hamming.go |
hamming distance calculations in Go
Copyright © 2014, 2015, 2016, 2018 Barry Allard
Performance
$ go test -bench=.
BenchmarkCountBitsInt8PopCnt-4 300000000 4.30 ns/op
BenchmarkCountBitsInt16PopCnt-4 300000000 3.83 ns/op
BenchmarkCountBitsInt32PopCnt-4 300000000 3.64 ns/op
BenchmarkCountBitsInt64PopCnt-4 500000000 3.60 ns/op
BenchmarkCountBitsIntPopCnt-4 300000000 5.72 ns/op
BenchmarkCountBitsUint8PopCnt-4 1000000000 2.98 ns/op
BenchmarkCountBitsUint16PopCnt-4 500000000 3.23 ns/op
BenchmarkCountBitsUint32PopCnt-4 500000000 3.00 ns/op
BenchmarkCountBitsUint64PopCnt-4 1000000000 2.94 ns/op
BenchmarkCountBitsUintPopCnt-4 300000000 5.04 ns/op
BenchmarkCountBitsBytePopCnt-4 300000000 3.99 ns/op
BenchmarkCountBitsRunePopCnt-4 300000000 3.83 ns/op
BenchmarkCountBitsInt8-4 2000000000 0.74 ns/op
BenchmarkCountBitsInt16-4 2000000000 1.54 ns/op
BenchmarkCountBitsInt32-4 1000000000 2.63 ns/op
BenchmarkCountBitsInt64-4 1000000000 2.56 ns/op
BenchmarkCountBitsInt-4 200000000 7.23 ns/op
BenchmarkCountBitsUint16-4 2000000000 1.51 ns/op
BenchmarkCountBitsUint32-4 500000000 4.00 ns/op
BenchmarkCountBitsUint64-4 1000000000 2.64 ns/op
BenchmarkCountBitsUint64Alt-4 200000000 7.60 ns/op
BenchmarkCountBitsUint-4 300000000 5.48 ns/op
BenchmarkCountBitsUintReference-4 100000000 19.2 ns/op
BenchmarkCountBitsByte-4 2000000000 0.75 ns/op
BenchmarkCountBitsByteAlt-4 1000000000 2.37 ns/op
BenchmarkCountBitsRune-4 500000000 2.85 ns/op
PASS
ok _/Users/bmf/Projects/hamming 58.305s
$
Usage
import 'github.com/steakknife/hamming'
// ...
// hamming distance between values
hamming.Byte(0xFF, 0x00) // 8
hamming.Byte(0x00, 0x00) // 0
// just count bits in a byte
hamming.CountBitsByte(0xA5), // 4
See help in the docs
Get
go get -u github.com/steakknife/hamming # master is always stable
Source
-
On the web: https://github.com/steakknife/hamming
-
Git:
git clone https://github.com/steakknife/hamming
Contact
License
Copyright © 2014, 2015, 2016 Barry Allard