Created
June 29, 2017 22:57
-
-
Save brentp/dc9815f71a601cfc67c9ee79c73632f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bit_test | |
import ( | |
"math/big" | |
"testing" | |
) | |
func BenchmarkUint64(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
var x uint64 | |
for j := uint64(0); j < 64; j++ { | |
x |= (1 << j) | |
} | |
} | |
} | |
func BenchmarkBig(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
x := big.NewInt(0) | |
for j := 0; j < 64; j++ { | |
x = x.SetBit(x, j, 1) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment