MCPcopy
hub / github.com/tdewolff/canvas / TestBentleyOttmannPerformance

Function TestBentleyOttmannPerformance

path_intersection_test.go:718–747  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

716}
717
718func TestBentleyOttmannPerformance(t *testing.T) {
719 var tts = []struct {
720 p string
721 op pathOp
722 q string
723 d time.Duration
724 r string
725 }{
726 // performance bug, takes >5s
727 {"M0.05603022976765715 -0.0003059739935906691L0.01800512753993644 -0.0030528993247571634z M0.024894563646512324 -0.002555207919613167L0.12000309429959088 -0.002555207919613167z", opSettle, "", 20 * time.Millisecond, ""},
728 {"M0.05603022976765715 -0.0003059739935906691L0.01800512753993644 -0.0030528993247571634z M0.05603022976765715 -0.0003059739935906691L0.024894563646512324 -0.002555207919613167L0.12000309429959088 -0.002555207919613167z", opSettle, "", 20 * time.Millisecond, "M0.02489459 -0.00255521L0.12000309 -0.00255521L0.05603023 -0.00030597z"},
729 }
730
731 for _, tt := range tts {
732 t.Run(fmt.Sprint(tt.p), func(t *testing.T) {
733 ps := MustParseSVGPath(tt.p).Split()
734 var qs []*Path
735 if tt.q != "" {
736 qs = MustParseSVGPath(tt.q).Split()
737 }
738
739 t0 := time.Now()
740 r := bentleyOttmann(ps, qs, tt.op, NonZero)
741 test.T(t, r.Merge(), MustParseSVGPath(tt.r))
742 if d := time.Since(t0); tt.d < d {
743 test.Fail(t, fmt.Sprintf("takes too long: %v instead of <%v", d, tt.d))
744 }
745 })
746 }
747}
748
749func TestPathSettle(t *testing.T) {
750 var tts = []struct {

Callers

nothing calls this directly

Calls 6

MustParseSVGPathFunction · 0.85
bentleyOttmannFunction · 0.85
SplitMethod · 0.80
TMethod · 0.80
MergeMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected