(b *testing.B)
| 957 | } |
| 958 | |
| 959 | func BenchmarkToRasterizer(b *testing.B) { |
| 960 | res := DPMM(10.0) |
| 961 | data, err := os.ReadFile("resources/netherlands.path") |
| 962 | if err != nil { |
| 963 | panic(err) |
| 964 | } |
| 965 | p, err := ParseSVGPath(string(data)) |
| 966 | if err != nil { |
| 967 | panic(err) |
| 968 | } |
| 969 | bounds := p.FastBounds() |
| 970 | p = p.Transform(Identity.Scale(1.0, -1.0).Translate(-bounds.X0, -bounds.Y1)) |
| 971 | |
| 972 | w, h := math.Ceil(float64(res)*bounds.W()), math.Ceil(float64(res)*bounds.H()) |
| 973 | rect := image.Rect(0, 0, int(w), int(h)) |
| 974 | img := image.NewRGBA(rect) |
| 975 | ras := &vector.Rasterizer{} |
| 976 | ras.Reset(int(w), int(h)) |
| 977 | |
| 978 | src := image.NewUniform(image.Black) |
| 979 | p.ToVectorRasterizer(ras, res) |
| 980 | ras.Draw(img, rect, src, image.Point{0, 0}) |
| 981 | |
| 982 | f, _ := os.Create("ToRasterizer.png") |
| 983 | defer f.Close() |
| 984 | (&png.Encoder{}).Encode(f, img) |
| 985 | |
| 986 | b.ResetTimer() |
| 987 | for i := 0; i < b.N; i++ { |
| 988 | ras.Reset(int(w), int(h)) |
| 989 | p.ToVectorRasterizer(ras, res) |
| 990 | ras.Draw(img, rect, src, image.Point{0, 0}) |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | func BenchmarkToScanx(b *testing.B) { |
| 995 | res := DPMM(10.0) |
nothing calls this directly
no test coverage detected