OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 package runtime_test | 4 package runtime_test |
5 | 5 |
6 import "testing" | 6 import "testing" |
7 | 7 |
8 const N = 20 | 8 const N = 20 |
9 | 9 |
10 func BenchmarkAppend(b *testing.B) { | 10 func BenchmarkAppend(b *testing.B) { |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 func BenchmarkAppend1Byte(b *testing.B) { | 33 func BenchmarkAppend1Byte(b *testing.B) { |
34 benchmarkAppendBytes(b, 1) | 34 benchmarkAppendBytes(b, 1) |
35 } | 35 } |
36 | 36 |
37 func BenchmarkAppend4Bytes(b *testing.B) { | 37 func BenchmarkAppend4Bytes(b *testing.B) { |
38 benchmarkAppendBytes(b, 4) | 38 benchmarkAppendBytes(b, 4) |
39 } | 39 } |
40 | 40 |
| 41 func BenchmarkAppend7Bytes(b *testing.B) { |
| 42 benchmarkAppendBytes(b, 7) |
| 43 } |
| 44 |
41 func BenchmarkAppend8Bytes(b *testing.B) { | 45 func BenchmarkAppend8Bytes(b *testing.B) { |
42 benchmarkAppendBytes(b, 8) | 46 benchmarkAppendBytes(b, 8) |
43 } | 47 } |
44 | 48 |
| 49 func BenchmarkAppend15Bytes(b *testing.B) { |
| 50 benchmarkAppendBytes(b, 15) |
| 51 } |
| 52 |
45 func BenchmarkAppend16Bytes(b *testing.B) { | 53 func BenchmarkAppend16Bytes(b *testing.B) { |
46 benchmarkAppendBytes(b, 16) | 54 benchmarkAppendBytes(b, 16) |
47 } | 55 } |
48 | 56 |
49 func BenchmarkAppend32Bytes(b *testing.B) { | 57 func BenchmarkAppend32Bytes(b *testing.B) { |
50 benchmarkAppendBytes(b, 32) | 58 benchmarkAppendBytes(b, 32) |
51 } | 59 } |
52 | 60 |
53 func benchmarkAppendStr(b *testing.B, str string) { | 61 func benchmarkAppendStr(b *testing.B, str string) { |
54 b.StopTimer() | 62 b.StopTimer() |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 122 |
115 func TestAppendOverlap(t *testing.T) { | 123 func TestAppendOverlap(t *testing.T) { |
116 x := []byte("1234") | 124 x := []byte("1234") |
117 x = append(x[1:], x...) // p > q in runtime·appendslice. | 125 x = append(x[1:], x...) // p > q in runtime·appendslice. |
118 got := string(x) | 126 got := string(x) |
119 want := "2341234" | 127 want := "2341234" |
120 if got != want { | 128 if got != want { |
121 t.Errorf("overlap failed: got %q want %q", got, want) | 129 t.Errorf("overlap failed: got %q want %q", got, want) |
122 } | 130 } |
123 } | 131 } |
OLD | NEW |