Skip to content

Commit 28a8db4

Browse files
author
Openset
committed
Add: Benchmark
1 parent 0b85ae0 commit 28a8db4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

problems/number-of-1-bits/number_of_1_bits_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ func TestHammingWeight(t *testing.T) {
2121
input: 8,
2222
expected: 1,
2323
},
24+
{
25+
input: 0x5555,
26+
expected: 8,
27+
},
2428
}
2529
for _, tc := range tests {
2630
output := hammingWeight(tc.input)
@@ -29,3 +33,9 @@ func TestHammingWeight(t *testing.T) {
2933
}
3034
}
3135
}
36+
37+
func BenchmarkHammingWeight(b *testing.B) {
38+
for i := 0; i < b.N; i++ {
39+
hammingWeight(0x55555555)
40+
}
41+
}

0 commit comments

Comments
 (0)