Debian Codegraph @

codec/bench/z_all_x_bench_test.go

raw symbols SCIP
1 //go:build alltests && go1.7 && x && !generated
2 // +build alltests,go1.7,x,!generated
3
4 // Copyright (c) 2012-2020 Ugorji Nwoke. All rights reserved.
5 // Use of this source code is governed by a MIT license found in the LICENSE file.
6
7 package codec
8
9 // see notes in z_all_bench_test.go
10
11 import "testing"
12
13 // Note: The following cannot parse TestStruc effectively,
14 // even with changes to remove arrays and minimize integer size to fit into int64 space.
15 //
16 // So we exclude them, listed below:
17 // encode: gcbor, xdr
18 // decode: gcbor, vmsgpack, xdr, sereal
19
20 func benchmarkXGroup(t *testing.B) {
21 benchmarkDivider()
22 t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode)
23 t.Run("Benchmark__Fxcbor_____Encode", Benchmark__Fxcbor_____Encode)
24 t.Run("Benchmark__Bson_______Encode", Benchmark__Bson_______Encode)
25 t.Run("Benchmark__Mgobson____Encode", Benchmark__Mgobson____Encode)
26 t.Run("Benchmark__VMsgpack___Encode", Benchmark__VMsgpack___Encode)
27 // t.Run("Benchmark__Gcbor______Encode", Benchmark__Gcbor______Encode)
28 // t.Run("Benchmark__Xdr________Encode", Benchmark__Xdr________Encode)
29 t.Run("Benchmark__Sereal_____Encode", Benchmark__Sereal_____Encode)
30
31 benchmarkDivider()
32 t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode)
33 t.Run("Benchmark__Fxcbor_____Decode", Benchmark__Fxcbor_____Decode)
34 t.Run("Benchmark__Bson_______Decode", Benchmark__Bson_______Decode)
35 t.Run("Benchmark__Mgobson____Decode", Benchmark__Mgobson____Decode)
36 t.Run("Benchmark__VMsgpack___Decode", Benchmark__VMsgpack___Decode)
37 // t.Run("Benchmark__Gcbor______Decode", Benchmark__Gcbor______Decode)
38 // t.Run("Benchmark__Xdr________Decode", Benchmark__Xdr________Decode)
39 // t.Run("Benchmark__Sereal_____Decode", Benchmark__Sereal_____Decode)
40 }
41
42 func benchmarkCodecXGroup(t *testing.B) {
43 benchmarkDivider()
44 t.Run("Benchmark__Msgpack____Encode", Benchmark__Msgpack____Encode)
45 t.Run("Benchmark__Binc_______Encode", Benchmark__Binc_______Encode)
46 t.Run("Benchmark__Simple_____Encode", Benchmark__Simple_____Encode)
47 t.Run("Benchmark__Cbor_______Encode", Benchmark__Cbor_______Encode)
48 t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode)
49 t.Run("Benchmark__Std_Json___Encode", Benchmark__Std_Json___Encode)
50 t.Run("Benchmark__Gob________Encode", Benchmark__Gob________Encode)
51 // t.Run("Benchmark__Std_Xml____Encode", Benchmark__Std_Xml____Encode)
52 t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode)
53 t.Run("Benchmark__Bson_______Encode", Benchmark__Bson_______Encode)
54 t.Run("Benchmark__Mgobson____Encode", Benchmark__Mgobson____Encode)
55 t.Run("Benchmark__VMsgpack___Encode", Benchmark__VMsgpack___Encode)
56 t.Run("Benchmark__Fxcbor_____Encode", Benchmark__Fxcbor_____Encode)
57 // t.Run("Benchmark__Gcbor______Encode", Benchmark__Gcbor______Encode)
58 // t.Run("Benchmark__Xdr________Encode", Benchmark__Xdr________Encode)
59 t.Run("Benchmark__Sereal_____Encode", Benchmark__Sereal_____Encode)
60
61 benchmarkDivider()
62 t.Run("Benchmark__Msgpack____Decode", Benchmark__Msgpack____Decode)
63 t.Run("Benchmark__Binc_______Decode", Benchmark__Binc_______Decode)
64 t.Run("Benchmark__Simple_____Decode", Benchmark__Simple_____Decode)
65 t.Run("Benchmark__Cbor_______Decode", Benchmark__Cbor_______Decode)
66 t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode)
67 t.Run("Benchmark__Std_Json___Decode", Benchmark__Std_Json___Decode)
68 t.Run("Benchmark__Gob________Decode", Benchmark__Gob________Decode)
69 // t.Run("Benchmark__Std_Xml____Decode", Benchmark__Std_Xml____Decode)
70 t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode)
71 t.Run("Benchmark__Bson_______Decode", Benchmark__Bson_______Decode)
72 t.Run("Benchmark__Mgobson____Decode", Benchmark__Mgobson____Decode)
73 t.Run("Benchmark__VMsgpack___Decode", Benchmark__VMsgpack___Decode)
74 t.Run("Benchmark__Fxcbor_____Decode", Benchmark__Fxcbor_____Decode)
75 // t.Run("Benchmark__Gcbor______Decode", Benchmark__Gcbor______Decode)
76 // t.Run("Benchmark__Xdr________Decode", Benchmark__Xdr________Decode)
77 // t.Run("Benchmark__Sereal_____Decode", Benchmark__Sereal_____Decode)
78 }
79
80 var benchmarkXSkipMsg = `>>>> Skipping - these cannot (en|de)code TestStruc - encode (xml, gcbor, xdr), decode (xml, gcbor, xdr, sereal)`
81
82 func BenchmarkXSuite(t *testing.B) {
83 println(benchmarkXSkipMsg)
84 benchmarkSuite(t, benchmarkXGroup)
85 }
86
87 func BenchmarkCodecXSuite(t *testing.B) {
88 println(benchmarkXSkipMsg)
89 benchmarkSuite(t, benchmarkCodecXGroup)
90 }
91
92 func benchmarkAllJsonEncodeGroup(t *testing.B) {
93 benchmarkDivider()
94 t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode)
95 t.Run("Benchmark__Std_Json___Encode", Benchmark__Std_Json___Encode)
96 t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode)
97 }
98
99 func benchmarkAllJsonDecodeGroup(t *testing.B) {
100 benchmarkDivider()
101 t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode)
102 t.Run("Benchmark__Std_Json___Decode", Benchmark__Std_Json___Decode)
103 t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode)
104 }
105
106 func BenchmarkCodecVeryQuickAllJsonSuite(t *testing.B) {
107 benchmarkVeryQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
108 }
109
110 func BenchmarkCodecQuickAllJsonSuite(t *testing.B) {
111 benchmarkQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
112 // benchmarkQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup)
113 // benchmarkQuickSuite(t, "json-all", benchmarkAllJsonDecodeGroup)
114
115 // depths := [...]int{1, 4}
116 // for _, d := range depths {
117 // benchmarkQuickSuite(t, d, benchmarkAllJsonEncodeGroup)
118 // benchmarkQuickSuite(t, d, benchmarkAllJsonDecodeGroup)
119 // }
120
121 // benchmarkQuickSuite(t, 1, benchmarkAllJsonEncodeGroup)
122 // benchmarkQuickSuite(t, 4, benchmarkAllJsonEncodeGroup)
123 // benchmarkQuickSuite(t, 1, benchmarkAllJsonDecodeGroup)
124 // benchmarkQuickSuite(t, 4, benchmarkAllJsonDecodeGroup)
125
126 // benchmarkQuickSuite(t, 1, benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
127 // benchmarkQuickSuite(t, 4, benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
128 // benchmarkQuickSuite(t, benchmarkAllJsonEncodeGroup)
129 // benchmarkQuickSuite(t, benchmarkAllJsonDecodeGroup)
130 }