xml_test.go 524 B

123456789101112131415161718192021222324252627282930313233
  1. package benchmarks
  2. import (
  3. "testing"
  4. "github.com/tdewolff/minify/xml"
  5. )
  6. var xmlSamples = []string{
  7. "sample_books.xml",
  8. "sample_catalog.xml",
  9. "sample_omg.xml",
  10. }
  11. func init() {
  12. for _, sample := range xmlSamples {
  13. load(sample)
  14. }
  15. }
  16. func BenchmarkXML(b *testing.B) {
  17. for _, sample := range xmlSamples {
  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. xml.Minify(m, w[sample], r[sample], nil)
  24. }
  25. })
  26. }
  27. }