项目作者: steakknife

项目描述 :
Hamming distance and bit counting primitives in Go (golang)
高级语言: Go
项目地址: git://github.com/steakknife/hamming.git
创建时间: 2014-06-20T23:09:55Z
项目社区:https://github.com/steakknife/hamming

开源协议:MIT License

下载


GoDoc Build Status

hamming distance calculations in Go

Copyright © 2014, 2015, 2016, 2018 Barry Allard

MIT license

Performance

  1. $ go test -bench=.
  2. BenchmarkCountBitsInt8PopCnt-4 300000000 4.30 ns/op
  3. BenchmarkCountBitsInt16PopCnt-4 300000000 3.83 ns/op
  4. BenchmarkCountBitsInt32PopCnt-4 300000000 3.64 ns/op
  5. BenchmarkCountBitsInt64PopCnt-4 500000000 3.60 ns/op
  6. BenchmarkCountBitsIntPopCnt-4 300000000 5.72 ns/op
  7. BenchmarkCountBitsUint8PopCnt-4 1000000000 2.98 ns/op
  8. BenchmarkCountBitsUint16PopCnt-4 500000000 3.23 ns/op
  9. BenchmarkCountBitsUint32PopCnt-4 500000000 3.00 ns/op
  10. BenchmarkCountBitsUint64PopCnt-4 1000000000 2.94 ns/op
  11. BenchmarkCountBitsUintPopCnt-4 300000000 5.04 ns/op
  12. BenchmarkCountBitsBytePopCnt-4 300000000 3.99 ns/op
  13. BenchmarkCountBitsRunePopCnt-4 300000000 3.83 ns/op
  14. BenchmarkCountBitsInt8-4 2000000000 0.74 ns/op
  15. BenchmarkCountBitsInt16-4 2000000000 1.54 ns/op
  16. BenchmarkCountBitsInt32-4 1000000000 2.63 ns/op
  17. BenchmarkCountBitsInt64-4 1000000000 2.56 ns/op
  18. BenchmarkCountBitsInt-4 200000000 7.23 ns/op
  19. BenchmarkCountBitsUint16-4 2000000000 1.51 ns/op
  20. BenchmarkCountBitsUint32-4 500000000 4.00 ns/op
  21. BenchmarkCountBitsUint64-4 1000000000 2.64 ns/op
  22. BenchmarkCountBitsUint64Alt-4 200000000 7.60 ns/op
  23. BenchmarkCountBitsUint-4 300000000 5.48 ns/op
  24. BenchmarkCountBitsUintReference-4 100000000 19.2 ns/op
  25. BenchmarkCountBitsByte-4 2000000000 0.75 ns/op
  26. BenchmarkCountBitsByteAlt-4 1000000000 2.37 ns/op
  27. BenchmarkCountBitsRune-4 500000000 2.85 ns/op
  28. PASS
  29. ok _/Users/bmf/Projects/hamming 58.305s
  30. $

Usage

  1. import 'github.com/steakknife/hamming'
  2. // ...
  3. // hamming distance between values
  4. hamming.Byte(0xFF, 0x00) // 8
  5. hamming.Byte(0x00, 0x00) // 0
  6. // just count bits in a byte
  7. hamming.CountBitsByte(0xA5), // 4

See help in the docs

Get

  1. go get -u github.com/steakknife/hamming # master is always stable

Source

Contact

License

MIT license

Copyright © 2014, 2015, 2016 Barry Allard