(b *testing.B)
| 98 | } |
| 99 | |
| 100 | func BenchmarkStandardJSON(b *testing.B) { |
| 101 | record := struct { |
| 102 | Level string `json:"level"` |
| 103 | Message string `json:"msg"` |
| 104 | Time time.Time `json:"ts"` |
| 105 | Fields map[string]interface{} `json:"fields"` |
| 106 | Additional StringSlice |
| 107 | }{ |
| 108 | Level: "debug", |
| 109 | Message: "fake", |
| 110 | Time: time.Unix(0, 0), |
| 111 | Fields: map[string]interface{}{ |
| 112 | "str": "foo", |
| 113 | "int64-1": int64(1), |
| 114 | "int64-2": int64(1), |
| 115 | "float64": float64(1.0), |
| 116 | "string1": "\n", |
| 117 | "string2": "💩", |
| 118 | "string3": "🤔", |
| 119 | "string4": "🙊", |
| 120 | "bool": true, |
| 121 | }, |
| 122 | Additional: generateStringSlice(_sliceSize), |
| 123 | } |
| 124 | b.ResetTimer() |
| 125 | b.RunParallel(func(pb *testing.PB) { |
| 126 | for pb.Next() { |
| 127 | if _, err := json.Marshal(record); err != nil { |
| 128 | b.Fatal(err) |
| 129 | } |
| 130 | } |
| 131 | }) |
| 132 | } |
nothing calls this directly
no test coverage detected