MCPcopy Create free account
hub / github.com/sergi/go-diff / BenchmarkCommonLength

Function BenchmarkCommonLength

diffmatchpatch/diff_test.go:149–179  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

147}
148
149func BenchmarkCommonLength(b *testing.B) {
150 data := []struct {
151 name string
152 x, y []rune
153 }{
154 {name: "empty", x: nil, y: []rune{}},
155 {name: "short", x: []rune("AABCC"), y: []rune("AA-CC")},
156 {name: "long",
157 x: []rune(strings.Repeat("A", 1000) + "B" + strings.Repeat("C", 1000)),
158 y: []rune(strings.Repeat("A", 1000) + "-" + strings.Repeat("C", 1000)),
159 },
160 }
161 b.Run("prefix", func(b *testing.B) {
162 for _, d := range data {
163 b.Run(d.name, func(b *testing.B) {
164 for i := 0; i < b.N; i++ {
165 SinkInt = commonPrefixLength(d.x, d.y)
166 }
167 })
168 }
169 })
170 b.Run("suffix", func(b *testing.B) {
171 for _, d := range data {
172 b.Run(d.name, func(b *testing.B) {
173 for i := 0; i < b.N; i++ {
174 SinkInt = commonSuffixLength(d.x, d.y)
175 }
176 })
177 }
178 })
179}
180
181func TestCommonSuffixLength(t *testing.T) {
182 type TestCase struct {

Callers

nothing calls this directly

Calls 2

commonPrefixLengthFunction · 0.85
commonSuffixLengthFunction · 0.85

Tested by

no test coverage detected