z_all_x_bench_test.go 5.7 KB

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