Skip to content

Instantly share code, notes, and snippets.

@brentp
Created June 29, 2017 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brentp/dc9815f71a601cfc67c9ee79c73632f7 to your computer and use it in GitHub Desktop.
Save brentp/dc9815f71a601cfc67c9ee79c73632f7 to your computer and use it in GitHub Desktop.
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