-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcolorjson_test.go
36 lines (30 loc) · 1.04 KB
/
colorjson_test.go
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
34
35
36
package colorjson_test
import "testing"
import "github.com/TylerBrock/colorjson"
import "github.com/hokaccha/go-prettyjson"
func benchmarkMarshall(i int, b *testing.B) {
simpleMap := make(map[string]interface{})
simpleMap["a"] = 1
simpleMap["b"] = "bee"
simpleMap["c"] = [3]float64{1, 2, 3}
simpleMap["d"] = [3]string{"one", "two", "three"}
// run the Fib function b.N times
for n := 0; n < b.N; n++ {
colorjson.Marshal(simpleMap)
}
}
func benchmarkPrettyJSON(i int, b *testing.B) {
simpleMap := make(map[string]interface{})
simpleMap["a"] = 1
simpleMap["b"] = "bee"
simpleMap["c"] = [3]float64{1, 2, 3}
simpleMap["d"] = [3]string{"one", "two", "three"}
// run the Fib function b.N times
for n := 0; n < b.N; n++ {
prettyjson.Marshal(simpleMap)
}
}
func BenchmarkMarshall(b *testing.B) { benchmarkMarshall(100, b) }
func BenchmarkMarshall1k(b *testing.B) { benchmarkMarshall(1000, b) }
func BenchmarkPrettyJSON(b *testing.B) { benchmarkPrettyJSON(100, b) }
func BenchmarkPrettyJSON1k(b *testing.B) { benchmarkPrettyJSON(1000, b) }