diff options
Diffstat (limited to 'libgo/go/bytes/bytes_test.go')
-rw-r--r-- | libgo/go/bytes/bytes_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libgo/go/bytes/bytes_test.go b/libgo/go/bytes/bytes_test.go index 6245e48..8df62fc 100644 --- a/libgo/go/bytes/bytes_test.go +++ b/libgo/go/bytes/bytes_test.go @@ -1255,3 +1255,34 @@ func BenchmarkRepeat(b *testing.B) { Repeat([]byte("-"), 80) } } + +func benchmarkBytesCompare(b *testing.B, n int) { + var x = make([]byte, n) + var y = make([]byte, n) + + for i := 0; i < n; i++ { + x[i] = 'a' + } + + for i := 0; i < n; i++ { + y[i] = 'a' + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + Compare(x, y) + } +} + +func BenchmarkBytesCompare1(b *testing.B) { benchmarkBytesCompare(b, 1) } +func BenchmarkBytesCompare2(b *testing.B) { benchmarkBytesCompare(b, 2) } +func BenchmarkBytesCompare4(b *testing.B) { benchmarkBytesCompare(b, 4) } +func BenchmarkBytesCompare8(b *testing.B) { benchmarkBytesCompare(b, 8) } +func BenchmarkBytesCompare16(b *testing.B) { benchmarkBytesCompare(b, 16) } +func BenchmarkBytesCompare32(b *testing.B) { benchmarkBytesCompare(b, 32) } +func BenchmarkBytesCompare64(b *testing.B) { benchmarkBytesCompare(b, 64) } +func BenchmarkBytesCompare128(b *testing.B) { benchmarkBytesCompare(b, 128) } +func BenchmarkBytesCompare256(b *testing.B) { benchmarkBytesCompare(b, 256) } +func BenchmarkBytesCompare512(b *testing.B) { benchmarkBytesCompare(b, 512) } +func BenchmarkBytesCompare1024(b *testing.B) { benchmarkBytesCompare(b, 1024) } +func BenchmarkBytesCompare2048(b *testing.B) { benchmarkBytesCompare(b, 2048) } |