(b *testing.B)
| 101 | } |
| 102 | |
| 103 | func BenchmarkDocumentParsing(b *testing.B) { |
| 104 | testImagesPath, err := filepath.Abs("../testdata/test-images/svg-test-suite") |
| 105 | if err != nil { |
| 106 | b.Fatal(err) |
| 107 | } |
| 108 | |
| 109 | samples := [][]byte{} |
| 110 | |
| 111 | err = filepath.Walk(testImagesPath, func(path string, info os.FileInfo, err error) error { |
| 112 | if err != nil { |
| 113 | b.Fatal(err) |
| 114 | } |
| 115 | |
| 116 | // Skip directories |
| 117 | if info.IsDir() { |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | // Skip non-SVG files |
| 122 | if filepath.Ext(path) != ".svg" { |
| 123 | return nil |
| 124 | } |
| 125 | |
| 126 | // Read SVG file |
| 127 | data, err := os.ReadFile(path) |
| 128 | if err != nil { |
| 129 | b.Fatal(err) |
| 130 | } |
| 131 | |
| 132 | samples = append(samples, data) |
| 133 | return nil |
| 134 | }) |
| 135 | |
| 136 | if err != nil { |
| 137 | b.Fatal(err) |
| 138 | } |
| 139 | |
| 140 | b.ResetTimer() |
| 141 | |
| 142 | for b.Loop() { |
| 143 | for _, sample := range samples { |
| 144 | _, err := xmlparser.NewDocument(bytes.NewReader(sample)) |
| 145 | if err != nil { |
| 146 | b.Fatal(err) |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | } |
nothing calls this directly
no test coverage detected