MCPcopy
hub / github.com/google/go-cmp / BenchmarkDifference

Function BenchmarkDifference

cmp/internal/diff/diff_test.go:295–308  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

293}
294
295func BenchmarkDifference(b *testing.B) {
296 for n := 1 << 10; n <= 1<<20; n <<= 2 {
297 b.Run(fmt.Sprintf("N%d", n), func(b *testing.B) {
298 x, y := generateStrings(n, 0.05, 0.05, 0.10, 0)
299 b.ReportAllocs()
300 b.SetBytes(int64(len(x) + len(y)))
301 for i := 0; i < b.N; i++ {
302 Difference(len(x), len(y), func(ix, iy int) Result {
303 return compareByte(x[ix], y[iy])
304 })
305 }
306 })
307 }
308}
309
310func generateStrings(n int, px, py, pm float32, seed int64) (string, string) {
311 if px+py+pm > 1.0 {

Callers

nothing calls this directly

Calls 3

generateStringsFunction · 0.85
DifferenceFunction · 0.85
compareByteFunction · 0.85

Tested by

no test coverage detected