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

Function BenchmarkPatchSplitMax

diffmatchpatch/patch_test.go:422–442  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

420}
421
422func BenchmarkPatchSplitMax(b *testing.B) {
423 s1, _ := speedtestTexts()
424
425 // Deleting every other character yields one big patch with many small diffs that must be split.
426 var diffs []Diff
427 for i := 0; i+1 < len(s1); i += 2 {
428 diffs = append(diffs, Diff{DiffEqual, s1[i : i+1]}, Diff{DiffDelete, s1[i+1 : i+2]})
429 }
430
431 dmp := New()
432 patches := dmp.PatchMake(s1, diffs)
433
434 b.ResetTimer()
435
436 for i := 0; i < b.N; i++ {
437 b.StopTimer()
438 p := dmp.PatchDeepCopy(patches)
439 b.StartTimer()
440 dmp.PatchSplitMax(p)
441 }
442}

Callers

nothing calls this directly

Calls 5

speedtestTextsFunction · 0.85
NewFunction · 0.85
PatchMakeMethod · 0.80
PatchDeepCopyMethod · 0.80
PatchSplitMaxMethod · 0.80

Tested by

no test coverage detected