• Robert Griesemer's avatar
    math/bits: faster OnesCount, added respective benchmarks · a12edb8d
    Robert Griesemer authored
    Also: Changed Reverse/ReverseBytes implementations to use
    the same (smaller) masks as OnesCount.
    
    BenchmarkOnesCount-8          37.0          6.26          -83.08%
    BenchmarkOnesCount8-8         7.24          1.99          -72.51%
    BenchmarkOnesCount16-8        11.3          2.47          -78.14%
    BenchmarkOnesCount32-8        18.4          3.02          -83.59%
    BenchmarkOnesCount64-8        40.0          3.78          -90.55%
    BenchmarkReverse-8            6.69          6.22          -7.03%
    BenchmarkReverse8-8           1.64          1.64          +0.00%
    BenchmarkReverse16-8          2.26          2.18          -3.54%
    BenchmarkReverse32-8          2.88          2.87          -0.35%
    BenchmarkReverse64-8          5.64          4.34          -23.05%
    BenchmarkReverseBytes-8       2.48          2.17          -12.50%
    BenchmarkReverseBytes16-8     0.63          0.95          +50.79%
    BenchmarkReverseBytes32-8     1.13          1.24          +9.73%
    BenchmarkReverseBytes64-8     2.50          2.16          -13.60%
    
    OnesCount-8       37.0ns ± 0%   6.3ns ± 0%   ~             (p=1.000 n=1+1)
    OnesCount8-8      7.24ns ± 0%  1.99ns ± 0%   ~             (p=1.000 n=1+1)
    OnesCount16-8     11.3ns ± 0%   2.5ns ± 0%   ~             (p=1.000 n=1+1)
    OnesCount32-8     18.4ns ± 0%   3.0ns ± 0%   ~             (p=1.000 n=1+1)
    OnesCount64-8     40.0ns ± 0%   3.8ns ± 0%   ~             (p=1.000 n=1+1)
    Reverse-8         6.69ns ± 0%  6.22ns ± 0%   ~             (p=1.000 n=1+1)
    Reverse8-8        1.64ns ± 0%  1.64ns ± 0%   ~     (all samples are equal)
    Reverse16-8       2.26ns ± 0%  2.18ns ± 0%   ~             (p=1.000 n=1+1)
    Reverse32-8       2.88ns ± 0%  2.87ns ± 0%   ~             (p=1.000 n=1+1)
    Reverse64-8       5.64ns ± 0%  4.34ns ± 0%   ~             (p=1.000 n=1+1)
    ReverseBytes-8    2.48ns ± 0%  2.17ns ± 0%   ~             (p=1.000 n=1+1)
    ReverseBytes16-8  0.63ns ± 0%  0.95ns ± 0%   ~             (p=1.000 n=1+1)
    ReverseBytes32-8  1.13ns ± 0%  1.24ns ± 0%   ~             (p=1.000 n=1+1)
    ReverseBytes64-8  2.50ns ± 0%  2.16ns ± 0%   ~             (p=1.000 n=1+1)
    
    Change-Id: I591b0ffc83fc3a42828256b6e5030f32c64f9497
    Reviewed-on: https://go-review.googlesource.com/37218Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
    a12edb8d
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...