(b *testing.B)
| 63 | } |
| 64 | |
| 65 | func BenchmarkSvgProcessing(b *testing.B) { |
| 66 | testImagesPath, err := filepath.Abs("../../testdata/test-images/svg-test-suite") |
| 67 | if err != nil { |
| 68 | b.Fatal(err) |
| 69 | } |
| 70 | |
| 71 | samples := []imagedata.ImageData{} |
| 72 | |
| 73 | err = filepath.Walk(testImagesPath, func(path string, info os.FileInfo, err error) error { |
| 74 | if err != nil { |
| 75 | b.Fatal(err) |
| 76 | } |
| 77 | |
| 78 | // Skip directories |
| 79 | if info.IsDir() { |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | // Skip non-SVG files |
| 84 | if filepath.Ext(path) != ".svg" { |
| 85 | return nil |
| 86 | } |
| 87 | |
| 88 | // Read SVG file |
| 89 | data, err := os.ReadFile(path) |
| 90 | if err != nil { |
| 91 | b.Fatal(err) |
| 92 | } |
| 93 | |
| 94 | samples = append(samples, imagedata.NewFromBytesWithFormat(imagetype.SVG, data)) |
| 95 | return nil |
| 96 | }) |
| 97 | |
| 98 | if err != nil { |
| 99 | b.Fatal(err) |
| 100 | } |
| 101 | |
| 102 | config := svg.NewDefaultConfig() |
| 103 | svgProc := svg.New(&config) |
| 104 | |
| 105 | opts := options.New() |
| 106 | |
| 107 | b.ResetTimer() |
| 108 | |
| 109 | for b.Loop() { |
| 110 | for _, sample := range samples { |
| 111 | _, err := svgProc.Process(opts, sample) |
| 112 | if err != nil { |
| 113 | b.Fatal(err) |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | } |
nothing calls this directly
no test coverage detected