}
}
+func benchmarkCompareBytesBigBothUnaligned(b *testing.B, offset int) {
+ b.StopTimer()
+ pattern := []byte("Hello Gophers!")
+ b1 := make([]byte, 0, 1<<20+len(pattern))
+ for len(b1) < 1<<20 {
+ b1 = append(b1, pattern...)
+ }
+ b2 := make([]byte, len(b1))
+ copy(b2, b1)
+ b.StartTimer()
+ for j := 0; j < b.N; j++ {
+ if Compare(b1[offset:], b2[offset:]) != 0 {
+ b.Fatal("b1 != b2")
+ }
+ }
+ b.SetBytes(int64(len(b1[offset:])))
+}
+
+func BenchmarkCompareBytesBigBothUnaligned(b *testing.B) {
+ for i := 0; i < 8; i++ {
+ b.Run(fmt.Sprintf("offset=%d", i), func(b *testing.B) {
+ benchmarkCompareBytesBigBothUnaligned(b, i)
+ })
+ }
+}
+
func BenchmarkCompareBytesBig(b *testing.B) {
b.StopTimer()
b1 := make([]byte, 0, 1<<20)