| 1 |
# benchmarks |
| 2 |
|
| 3 |
Disclaimer: `go-openapi` has no affiliation with the providers of the tested libraries. |
| 4 |
|
| 5 |
Credits: the definition of the small, medium and large payloads has been taken from the benchmarks |
| 6 |
published at `github.com/goccy/go-json`. Thanks @goccy. We'd love to include your library as one |
| 7 |
of our supported adapters. |
| 8 |
|
| 9 |
This benchmark is not a competitive benchmark, but merely a way for us to ensure that |
| 10 |
our "JSON adapter" feature runs with good performances and induces a reasonably low overhead. |
| 11 |
|
| 12 |
Expected behavior: the `Adapter` layer is relatively thin: it involves no extra allocation |
| 13 |
> and its CPU impact is negligible when compared to the Marshal/Unmarshal tasks. |
| 14 |
> |
| 15 |
> NOTE: the `FromDynamicJSON` benchmark uses both source and target types supporting `easyjson`, |
| 16 |
> which equates more or less to a deep copy of the original payload. |
| 17 |
> |
| 18 |
> Using `any` as a target would systematically route to the standard library and therefore, results |
| 19 |
> wouldn't represent a fair comparison. |
| 20 |
|
| 21 |
## go1.25.0 |
| 22 |
|
| 23 |
 |
| 24 |
|
| 25 |
```sh |
| 26 |
go version go1.25.0 linux/amd64 |
| 27 |
``` |
| 28 |
|
| 29 |
```sh |
| 30 |
go test -v -bench . -run Bench -benchtime 30s -benchmem |
| 31 |
``` |
| 32 |
|
| 33 |
``` |
| 34 |
goos: linux |
| 35 |
goarch: amd64 |
| 36 |
pkg: github.com/go-openapi/swag/jsonutils/adapters/testintegration/benchmarks |
| 37 |
cpu: AMD Ryzen 7 5800X 8-Core Processor |
| 38 |
BenchmarkJSON |
| 39 |
BenchmarkJSON/with_standard_library |
| 40 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_small |
| 41 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_small-16 13005949 3020 ns/op 47.68 MB/s 416 B/op 9 allocs/op |
| 42 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_small |
| 43 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_small-16 56078876 614.1 ns/op 214.94 MB/s 144 B/op 1 allocs/op |
| 44 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_small |
| 45 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_small-16 10574182 3487 ns/op 560 B/op 10 allocs/op |
| 46 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_medium |
| 47 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_medium-16 2235476 15966 ns/op 129.65 MB/s 624 B/op 18 allocs/op |
| 48 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_medium |
| 49 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_medium-16 25711994 1379 ns/op 229.10 MB/s 320 B/op 1 allocs/op |
| 50 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_medium |
| 51 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_medium-16 4111292 9339 ns/op 1233 B/op 37 allocs/op |
| 52 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_large |
| 53 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_large-16 180291 190534 ns/op 147.58 MB/s 4435 B/op 147 allocs/op |
| 54 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_large |
| 55 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_large-16 1783418 20211 ns/op 239.33 MB/s 4871 B/op 1 allocs/op |
| 56 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_large |
| 57 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_large-16 261943 140796 ns/op 15249 B/op 428 allocs/op |
| 58 |
BenchmarkJSON/with_easyjson_library |
| 59 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_small |
| 60 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_small-16 43712187 858.3 ns/op 167.77 MB/s 192 B/op 5 allocs/op |
| 61 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_small |
| 62 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_small-16 64595014 524.5 ns/op 251.68 MB/s 720 B/op 4 allocs/op |
| 63 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_small |
| 64 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_small-16 22922629 1500 ns/op 913 B/op 9 allocs/op |
| 65 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_medium |
| 66 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_medium-16 4939929 7306 ns/op 283.33 MB/s 256 B/op 9 allocs/op |
| 67 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_medium |
| 68 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_medium-16 39401455 917.5 ns/op 344.40 MB/s 897 B/op 4 allocs/op |
| 69 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_medium |
| 70 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_medium-16 9979048 3233 ns/op 1322 B/op 28 allocs/op |
| 71 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_large |
| 72 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_large-16 486135 75891 ns/op 370.51 MB/s 3912 B/op 132 allocs/op |
| 73 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_large |
| 74 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_large-16 3888386 9140 ns/op 529.20 MB/s 5567 B/op 8 allocs/op |
| 75 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_large |
| 76 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_large-16 717406 47115 ns/op 15496 B/op 421 allocs/op |
| 77 |
PASS |
| 78 |
ok github.com/go-openapi/swag/jsonutils/adapters/testintegration/benchmarks 643.940s |
| 79 |
``` |
| 80 |
|
| 81 |
## go1.25.0 greenteagc |
| 82 |
|
| 83 |
```sh |
| 84 |
go version go1.25.0 linux/amd64 |
| 85 |
``` |
| 86 |
|
| 87 |
```sh |
| 88 |
GOEXPERIMENT=greenteagc go test -v -bench . -run Bench -benchtime 30s -benchmem |
| 89 |
``` |
| 90 |
|
| 91 |
``` |
| 92 |
goos: linux |
| 93 |
goarch: amd64 |
| 94 |
pkg: github.com/go-openapi/swag/jsonutils/adapters/testintegration/benchmarks |
| 95 |
cpu: AMD Ryzen 7 5800X 8-Core Processor |
| 96 |
BenchmarkJSON |
| 97 |
BenchmarkJSON/with_standard_library |
| 98 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_small |
| 99 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_small-16 12759744 2747 ns/op 52.42 MB/s 416 B/op 9 allocs/op |
| 100 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_small |
| 101 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_small-16 63616329 577.5 ns/op 228.59 MB/s 144 B/op 1 allocs/op |
| 102 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_small |
| 103 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_small-16 10593036 3308 ns/op 560 B/op 10 allocs/op |
| 104 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_medium |
| 105 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_medium-16 2195624 16308 ns/op 126.94 MB/s 624 B/op 18 allocs/op |
| 106 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_medium |
| 107 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_medium-16 28557896 1229 ns/op 257.18 MB/s 320 B/op 1 allocs/op |
| 108 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_medium |
| 109 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_medium-16 3964765 9088 ns/op 1234 B/op 37 allocs/op |
| 110 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_large |
| 111 |
BenchmarkJSON/with_standard_library/standard_ReadJSON_-_large-16 189339 193019 ns/op 145.67 MB/s 4435 B/op 147 allocs/op |
| 112 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_large |
| 113 |
BenchmarkJSON/with_standard_library/standard_WriteJSON_-_large-16 1998580 17652 ns/op 274.01 MB/s 4870 B/op 1 allocs/op |
| 114 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_large |
| 115 |
BenchmarkJSON/with_standard_library/standard_FromDynamicJSON_-_large-16 255865 140575 ns/op 15247 B/op 428 allocs/op |
| 116 |
BenchmarkJSON/with_easyjson_library |
| 117 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_small |
| 118 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_small-16 44697164 868.3 ns/op 165.84 MB/s 192 B/op 5 allocs/op |
| 119 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_small |
| 120 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_small-16 60345216 534.8 ns/op 246.80 MB/s 720 B/op 4 allocs/op |
| 121 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_small |
| 122 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_small-16 26356634 1477 ns/op 913 B/op 9 allocs/op |
| 123 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_medium |
| 124 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_medium-16 5074519 7145 ns/op 289.72 MB/s 256 B/op 9 allocs/op |
| 125 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_medium |
| 126 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_medium-16 41205440 867.0 ns/op 364.46 MB/s 897 B/op 4 allocs/op |
| 127 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_medium |
| 128 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_medium-16 11434189 3068 ns/op 1322 B/op 28 allocs/op |
| 129 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_large |
| 130 |
BenchmarkJSON/with_easyjson_library/easyjson_ReadJSON_-_large-16 471589 76075 ns/op 369.61 MB/s 3912 B/op 132 allocs/op |
| 131 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_large |
| 132 |
BenchmarkJSON/with_easyjson_library/easyjson_WriteJSON_-_large-16 3816392 9151 ns/op 528.57 MB/s 5565 B/op 8 allocs/op |
| 133 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_large |
| 134 |
BenchmarkJSON/with_easyjson_library/easyjson_FromDynamicJSON_-_large-16 751338 46537 ns/op 15502 B/op 421 allocs/op |
| 135 |
PASS |
| 136 |
ok github.com/go-openapi/swag/jsonutils/adapters/testintegration/benchmarks 644.394s |
| 137 |
``` |