aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/tdewolff/minify/benchmarks/json_test.go
blob: 3d9f344c8133ec3580d6f8f05d1a76005ea79345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package benchmarks

import (
	"testing"

	"github.com/tdewolff/minify/json"
)

var jsonSamples = []string{
	"sample_large.json",
	"sample_testsuite.json",
	"sample_twitter.json",
}

func init() {
	for _, sample := range jsonSamples {
		load(sample)
	}
}

func BenchmarkJSON(b *testing.B) {
	for _, sample := range jsonSamples {
		b.Run(sample, func(b *testing.B) {
			b.SetBytes(int64(r[sample].Len()))

			for i := 0; i < b.N; i++ {
				r[sample].Reset()
				w[sample].Reset()
				json.Minify(m, w[sample], r[sample], nil)
			}
		})
	}
}