svg_test.go 524 B

123456789101112131415161718192021222324252627282930313233
  1. package benchmarks
  2. import (
  3. "testing"
  4. "github.com/tdewolff/minify/svg"
  5. )
  6. var svgSamples = []string{
  7. "sample_arctic.svg",
  8. "sample_gopher.svg",
  9. "sample_usa.svg",
  10. }
  11. func init() {
  12. for _, sample := range svgSamples {
  13. load(sample)
  14. }
  15. }
  16. func BenchmarkSVG(b *testing.B) {
  17. for _, sample := range svgSamples {
  18. b.Run(sample, func(b *testing.B) {
  19. b.SetBytes(int64(r[sample].Len()))
  20. for i := 0; i < b.N; i++ {
  21. r[sample].Reset()
  22. w[sample].Reset()
  23. svg.Minify(m, w[sample], r[sample], nil)
  24. }
  25. })
  26. }
  27. }