File: z_all_x_bench_test.go

package info (click to toggle)
golang-github-ugorji-go-codec 1.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, experimental, forky, sid, trixie
  • size: 2,532 kB
  • sloc: sh: 462; python: 100; makefile: 4
file content (130 lines) | stat: -rw-r--r-- 6,140 bytes parent folder | download
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//go:build alltests && go1.7 && x && !generated
// +build alltests,go1.7,x,!generated

// Copyright (c) 2012-2020 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.

package codec

// see notes in z_all_bench_test.go

import "testing"

// Note: The following cannot parse TestStruc effectively,
// even with changes to remove arrays and minimize integer size to fit into int64 space.
//
// So we exclude them, listed below:
// encode: gcbor, xdr
// decode: gcbor, vmsgpack, xdr, sereal

func benchmarkXGroup(t *testing.B) {
	benchmarkDivider()
	t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode)
	t.Run("Benchmark__Fxcbor_____Encode", Benchmark__Fxcbor_____Encode)
	t.Run("Benchmark__Bson_______Encode", Benchmark__Bson_______Encode)
	t.Run("Benchmark__Mgobson____Encode", Benchmark__Mgobson____Encode)
	t.Run("Benchmark__VMsgpack___Encode", Benchmark__VMsgpack___Encode)
	// t.Run("Benchmark__Gcbor______Encode", Benchmark__Gcbor______Encode)
	// t.Run("Benchmark__Xdr________Encode", Benchmark__Xdr________Encode)
	t.Run("Benchmark__Sereal_____Encode", Benchmark__Sereal_____Encode)

	benchmarkDivider()
	t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode)
	t.Run("Benchmark__Fxcbor_____Decode", Benchmark__Fxcbor_____Decode)
	t.Run("Benchmark__Bson_______Decode", Benchmark__Bson_______Decode)
	t.Run("Benchmark__Mgobson____Decode", Benchmark__Mgobson____Decode)
	t.Run("Benchmark__VMsgpack___Decode", Benchmark__VMsgpack___Decode)
	// t.Run("Benchmark__Gcbor______Decode", Benchmark__Gcbor______Decode)
	// t.Run("Benchmark__Xdr________Decode", Benchmark__Xdr________Decode)
	// t.Run("Benchmark__Sereal_____Decode", Benchmark__Sereal_____Decode)
}

func benchmarkCodecXGroup(t *testing.B) {
	benchmarkDivider()
	t.Run("Benchmark__Msgpack____Encode", Benchmark__Msgpack____Encode)
	t.Run("Benchmark__Binc_______Encode", Benchmark__Binc_______Encode)
	t.Run("Benchmark__Simple_____Encode", Benchmark__Simple_____Encode)
	t.Run("Benchmark__Cbor_______Encode", Benchmark__Cbor_______Encode)
	t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode)
	t.Run("Benchmark__Std_Json___Encode", Benchmark__Std_Json___Encode)
	t.Run("Benchmark__Gob________Encode", Benchmark__Gob________Encode)
	// t.Run("Benchmark__Std_Xml____Encode", Benchmark__Std_Xml____Encode)
	t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode)
	t.Run("Benchmark__Bson_______Encode", Benchmark__Bson_______Encode)
	t.Run("Benchmark__Mgobson____Encode", Benchmark__Mgobson____Encode)
	t.Run("Benchmark__VMsgpack___Encode", Benchmark__VMsgpack___Encode)
	t.Run("Benchmark__Fxcbor_____Encode", Benchmark__Fxcbor_____Encode)
	// t.Run("Benchmark__Gcbor______Encode", Benchmark__Gcbor______Encode)
	// t.Run("Benchmark__Xdr________Encode", Benchmark__Xdr________Encode)
	t.Run("Benchmark__Sereal_____Encode", Benchmark__Sereal_____Encode)

	benchmarkDivider()
	t.Run("Benchmark__Msgpack____Decode", Benchmark__Msgpack____Decode)
	t.Run("Benchmark__Binc_______Decode", Benchmark__Binc_______Decode)
	t.Run("Benchmark__Simple_____Decode", Benchmark__Simple_____Decode)
	t.Run("Benchmark__Cbor_______Decode", Benchmark__Cbor_______Decode)
	t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode)
	t.Run("Benchmark__Std_Json___Decode", Benchmark__Std_Json___Decode)
	t.Run("Benchmark__Gob________Decode", Benchmark__Gob________Decode)
	// t.Run("Benchmark__Std_Xml____Decode", Benchmark__Std_Xml____Decode)
	t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode)
	t.Run("Benchmark__Bson_______Decode", Benchmark__Bson_______Decode)
	t.Run("Benchmark__Mgobson____Decode", Benchmark__Mgobson____Decode)
	t.Run("Benchmark__VMsgpack___Decode", Benchmark__VMsgpack___Decode)
	t.Run("Benchmark__Fxcbor_____Decode", Benchmark__Fxcbor_____Decode)
	// t.Run("Benchmark__Gcbor______Decode", Benchmark__Gcbor______Decode)
	// t.Run("Benchmark__Xdr________Decode", Benchmark__Xdr________Decode)
	// t.Run("Benchmark__Sereal_____Decode", Benchmark__Sereal_____Decode)
}

var benchmarkXSkipMsg = `>>>> Skipping - these cannot (en|de)code TestStruc - encode (xml, gcbor, xdr), decode (xml, gcbor, xdr, sereal)`

func BenchmarkXSuite(t *testing.B) {
	println(benchmarkXSkipMsg)
	benchmarkSuite(t, benchmarkXGroup)
}

func BenchmarkCodecXSuite(t *testing.B) {
	println(benchmarkXSkipMsg)
	benchmarkSuite(t, benchmarkCodecXGroup)
}

func benchmarkAllJsonEncodeGroup(t *testing.B) {
	benchmarkDivider()
	t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode)
	t.Run("Benchmark__Std_Json___Encode", Benchmark__Std_Json___Encode)
	t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode)
}

func benchmarkAllJsonDecodeGroup(t *testing.B) {
	benchmarkDivider()
	t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode)
	t.Run("Benchmark__Std_Json___Decode", Benchmark__Std_Json___Decode)
	t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode)
}

func BenchmarkCodecVeryQuickAllJsonSuite(t *testing.B) {
	benchmarkVeryQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
}

func BenchmarkCodecQuickAllJsonSuite(t *testing.B) {
	benchmarkQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
	// benchmarkQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup)
	// benchmarkQuickSuite(t, "json-all", benchmarkAllJsonDecodeGroup)

	// depths := [...]int{1, 4}
	// for _, d := range depths {
	// 	benchmarkQuickSuite(t, d, benchmarkAllJsonEncodeGroup)
	// 	benchmarkQuickSuite(t, d, benchmarkAllJsonDecodeGroup)
	// }

	// benchmarkQuickSuite(t, 1, benchmarkAllJsonEncodeGroup)
	// benchmarkQuickSuite(t, 4, benchmarkAllJsonEncodeGroup)
	// benchmarkQuickSuite(t, 1, benchmarkAllJsonDecodeGroup)
	// benchmarkQuickSuite(t, 4, benchmarkAllJsonDecodeGroup)

	// benchmarkQuickSuite(t, 1, benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
	// benchmarkQuickSuite(t, 4, benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup)
	// benchmarkQuickSuite(t, benchmarkAllJsonEncodeGroup)
	// benchmarkQuickSuite(t, benchmarkAllJsonDecodeGroup)
}