We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f25fcb0 commit 293f204Copy full SHA for 293f204
wsjson/wsjson_test.go
@@ -0,0 +1,24 @@
1
+package wsjson_test
2
+
3
+import (
4
+ "encoding/json"
5
+ "io"
6
+ "strings"
7
+ "testing"
8
+)
9
10
+func BenchmarkJSON(b *testing.B) {
11
+ msg := []byte(strings.Repeat("1234", 128))
12
+ b.SetBytes(int64(len(msg)))
13
+ b.ReportAllocs()
14
+ b.Run("json.Encoder", func(b *testing.B) {
15
+ for i := 0; i < b.N; i++ {
16
+ json.NewEncoder(io.Discard).Encode(msg)
17
+ }
18
+ })
19
+ b.Run("json.Marshal", func(b *testing.B) {
20
21
+ json.Marshal(msg)
22
23
24
+}
0 commit comments