benchmarkSizes(b, bufSizes, func(b *testing.B, n int) {
x := make([]byte, n)
y := make([]byte, n)
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
copy(x, y)
}
func BenchmarkMemmoveOverlap(b *testing.B) {
benchmarkSizes(b, bufSizesOverlap, func(b *testing.B, n int) {
x := make([]byte, n+16)
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
copy(x[16:n+16], x[:n])
}
benchmarkSizes(b, bufSizes, func(b *testing.B, n int) {
x := make([]byte, n+1)
y := make([]byte, n)
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
copy(x[1:], y)
}
func BenchmarkMemmoveUnalignedDstOverlap(b *testing.B) {
benchmarkSizes(b, bufSizesOverlap, func(b *testing.B, n int) {
x := make([]byte, n+16)
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
copy(x[16:n+16], x[1:n+1])
}
benchmarkSizes(b, bufSizes, func(b *testing.B, n int) {
x := make([]byte, n)
y := make([]byte, n+1)
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
copy(x, y[1:])
}
func BenchmarkMemmoveUnalignedSrcOverlap(b *testing.B) {
benchmarkSizes(b, bufSizesOverlap, func(b *testing.B, n int) {
x := make([]byte, n+1)
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
copy(x[1:n+1], x[:n])
}
func BenchmarkGoMemclr(b *testing.B) {
benchmarkSizes(b, []int{5, 16, 64, 256}, func(b *testing.B, n int) {
x := make([]byte, n)
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
clear(x)
}