README.md (5426B)
1 # go-hex 2 3 [![GoDoc](https://godoc.org/github.com/tmthrgd/go-hex?status.svg)](https://godoc.org/github.com/tmthrgd/go-hex) 4 [![Build Status](https://travis-ci.org/tmthrgd/go-hex.svg?branch=master)](https://travis-ci.org/tmthrgd/go-hex) 5 6 An efficient hexadecimal implementation for Golang. 7 8 go-hex provides hex encoding and decoding using SSE/AVX instructions on x86-64. 9 10 ## Download 11 12 ``` 13 go get github.com/tmthrgd/go-hex 14 ``` 15 16 ## Benchmark 17 18 go-hex: 19 ``` 20 BenchmarkEncode/15-8 100000000 17.4 ns/op 863.43 MB/s 21 BenchmarkEncode/32-8 100000000 11.9 ns/op 2690.43 MB/s 22 BenchmarkEncode/128-8 100000000 21.4 ns/op 5982.92 MB/s 23 BenchmarkEncode/1k-8 20000000 88.5 ns/op 11572.80 MB/s 24 BenchmarkEncode/16k-8 1000000 1254 ns/op 13058.10 MB/s 25 BenchmarkEncode/128k-8 100000 12965 ns/op 10109.53 MB/s 26 BenchmarkEncode/1M-8 10000 119465 ns/op 8777.23 MB/s 27 BenchmarkEncode/16M-8 500 3530380 ns/op 4752.24 MB/s 28 BenchmarkEncode/128M-8 50 28001913 ns/op 4793.16 MB/s 29 BenchmarkDecode/14-8 100000000 12.6 ns/op 1110.01 MB/s 30 BenchmarkDecode/32-8 100000000 12.5 ns/op 2558.10 MB/s 31 BenchmarkDecode/128-8 50000000 27.2 ns/op 4697.66 MB/s 32 BenchmarkDecode/1k-8 10000000 168 ns/op 6093.43 MB/s 33 BenchmarkDecode/16k-8 500000 2543 ns/op 6442.09 MB/s 34 BenchmarkDecode/128k-8 100000 20339 ns/op 6444.24 MB/s 35 BenchmarkDecode/1M-8 10000 164313 ns/op 6381.57 MB/s 36 BenchmarkDecode/16M-8 500 3099822 ns/op 5412.31 MB/s 37 BenchmarkDecode/128M-8 50 24865822 ns/op 5397.68 MB/s 38 ``` 39 40 [encoding/hex](https://golang.org/pkg/encoding/hex/): 41 ``` 42 BenchmarkRefEncode/15-8 50000000 36.1 ns/op 415.07 MB/s 43 BenchmarkRefEncode/32-8 20000000 72.9 ns/op 439.14 MB/s 44 BenchmarkRefEncode/128-8 5000000 289 ns/op 441.54 MB/s 45 BenchmarkRefEncode/1k-8 1000000 2268 ns/op 451.49 MB/s 46 BenchmarkRefEncode/16k-8 30000 39110 ns/op 418.91 MB/s 47 BenchmarkRefEncode/128k-8 5000 291260 ns/op 450.02 MB/s 48 BenchmarkRefEncode/1M-8 1000 2277578 ns/op 460.39 MB/s 49 BenchmarkRefEncode/16M-8 30 37087543 ns/op 452.37 MB/s 50 BenchmarkRefEncode/128M-8 5 293611713 ns/op 457.13 MB/s 51 BenchmarkRefDecode/14-8 30000000 53.7 ns/op 260.49 MB/s 52 BenchmarkRefDecode/32-8 10000000 128 ns/op 248.44 MB/s 53 BenchmarkRefDecode/128-8 3000000 481 ns/op 265.95 MB/s 54 BenchmarkRefDecode/1k-8 300000 4172 ns/op 245.43 MB/s 55 BenchmarkRefDecode/16k-8 10000 111989 ns/op 146.30 MB/s 56 BenchmarkRefDecode/128k-8 2000 909077 ns/op 144.18 MB/s 57 BenchmarkRefDecode/1M-8 200 7275779 ns/op 144.12 MB/s 58 BenchmarkRefDecode/16M-8 10 116574839 ns/op 143.92 MB/s 59 BenchmarkRefDecode/128M-8 2 933871637 ns/op 143.72 MB/s 60 ``` 61 62 [encoding/hex](https://golang.org/pkg/encoding/hex/) -> go-hex: 63 ``` 64 benchmark old ns/op new ns/op delta 65 BenchmarkEncode/15-8 36.1 17.4 -51.80% 66 BenchmarkEncode/32-8 72.9 11.9 -83.68% 67 BenchmarkEncode/128-8 289 21.4 -92.60% 68 BenchmarkEncode/1k-8 2268 88.5 -96.10% 69 BenchmarkEncode/16k-8 39110 1254 -96.79% 70 BenchmarkEncode/128k-8 291260 12965 -95.55% 71 BenchmarkEncode/1M-8 2277578 119465 -94.75% 72 BenchmarkEncode/16M-8 37087543 3530380 -90.48% 73 BenchmarkEncode/128M-8 293611713 28001913 -90.46% 74 BenchmarkDecode/14-8 53.7 12.6 -76.54% 75 BenchmarkDecode/32-8 128 12.5 -90.23% 76 BenchmarkDecode/128-8 481 27.2 -94.35% 77 BenchmarkDecode/1k-8 4172 168 -95.97% 78 BenchmarkDecode/16k-8 111989 2543 -97.73% 79 BenchmarkDecode/128k-8 909077 20339 -97.76% 80 BenchmarkDecode/1M-8 7275779 164313 -97.74% 81 BenchmarkDecode/16M-8 116574839 3099822 -97.34% 82 BenchmarkDecode/128M-8 933871637 24865822 -97.34% 83 84 benchmark old MB/s new MB/s speedup 85 BenchmarkEncode/15-8 415.07 863.43 2.08x 86 BenchmarkEncode/32-8 439.14 2690.43 6.13x 87 BenchmarkEncode/128-8 441.54 5982.92 13.55x 88 BenchmarkEncode/1k-8 451.49 11572.80 25.63x 89 BenchmarkEncode/16k-8 418.91 13058.10 31.17x 90 BenchmarkEncode/128k-8 450.02 10109.53 22.46x 91 BenchmarkEncode/1M-8 460.39 8777.23 19.06x 92 BenchmarkEncode/16M-8 452.37 4752.24 10.51x 93 BenchmarkEncode/128M-8 457.13 4793.16 10.49x 94 BenchmarkDecode/14-8 260.49 1110.01 4.26x 95 BenchmarkDecode/32-8 248.44 2558.10 10.30x 96 BenchmarkDecode/128-8 265.95 4697.66 17.66x 97 BenchmarkDecode/1k-8 245.43 6093.43 24.83x 98 BenchmarkDecode/16k-8 146.30 6442.09 44.03x 99 BenchmarkDecode/128k-8 144.18 6444.24 44.70x 100 BenchmarkDecode/1M-8 144.12 6381.57 44.28x 101 BenchmarkDecode/16M-8 143.92 5412.31 37.61x 102 BenchmarkDecode/128M-8 143.72 5397.68 37.56x 103 ``` 104 105 ## License 106 107 Unless otherwise noted, the go-hex source files are distributed under the Modified BSD License 108 found in the LICENSE file.