html_test.go 611 B

123456789101112131415161718192021222324252627282930313233343536
  1. package benchmarks
  2. import (
  3. "testing"
  4. "github.com/tdewolff/minify/html"
  5. )
  6. var htmlSamples = []string{
  7. "sample_amazon.html",
  8. "sample_bbc.html",
  9. "sample_blogpost.html",
  10. "sample_es6.html",
  11. "sample_stackoverflow.html",
  12. "sample_wikipedia.html",
  13. }
  14. func init() {
  15. for _, sample := range htmlSamples {
  16. load(sample)
  17. }
  18. }
  19. func BenchmarkHTML(b *testing.B) {
  20. for _, sample := range htmlSamples {
  21. b.Run(sample, func(b *testing.B) {
  22. b.SetBytes(int64(r[sample].Len()))
  23. for i := 0; i < b.N; i++ {
  24. r[sample].Reset()
  25. w[sample].Reset()
  26. html.Minify(m, w[sample], r[sample], nil)
  27. }
  28. })
  29. }
  30. }