Large Vectors
This benchmarks checks to see how well a structure containing different enum fields can be serialized and deserialized. The enum have different sized variants (u8, u32, i64) and are instantiated with different values.
#![allow(unused)] fn main() { #[repr(u8)] enum Color { Red = 1, Green = 2, Blue = 3, Yellow = 100, Cyan = 101, Magenta = 102, } #[repr(u32)] enum Math { A = 1, B = 1000, C = 1000000, D = 1000000000, } #[repr(i64)] enum Negative { A = 1, B = -1000, C = 1000000, D = -1000000000, E = 1000000000000, F = -1000000000000000, } pub struct EnumFields { col: Color, math: Math, neg: Negative, } }
Test specs
- Iterations:
k = 10
- Serialization and deserialization repetitions / iteration:
n = 500000
- Data size:
13
bytes - Protobuf: Not Supported (enums can't be used directly in protobuf via prost crate)
Results
1. Windows Execution
Algorithm | Size (b) | Ser. (ms) | Deser. (ms) | Ser+Deser.(ms) |
---|---|---|---|---|
postcard (schema) | 3 [ -77%] | 2.45 [ 1.70 - 2.97] | 4.66 [ 2.93 - 4.84] | 6.38 [ 4.24 - 6.54] |
FlatMessage (⚠️) | 51 [+292%] | 2.41 [ 1.71 - 2.52] | 5.84 [ 4.17 - 7.11] | 7.04 [ 5.11 - 8.29] |
FlatMessage | 51 [+292%] | 2.18 [ 1.44 - 2.65] | 6.18 [ 4.15 - 7.37] | 7.10 [ 5.09 - 8.72] |
bincode (schema) | 3 [ -77%] | 6.80 [ 4.79 - 8.42] | 8.00 [ 5.91 - 8.98] | 17.42 [ 12.30 - 19.38] |
rmp (schema) | 13 [ +0%] | 5.62 [ 4.19 - 6.69] | 27.57 [ 20.13 - 32.89] | 34.42 [ 25.33 - 40.73] |
rmp | 26 [+100%] | 7.44 [ 5.63 - 8.74] | 46.45 [ 34.02 - 54.01] | 53.70 [ 39.64 - 62.60] |
json | 38 [+192%] | 33.50 [ 24.57 - 37.36] | 78.92 [ 58.62 - 91.34] | 112.82 [ 82.15 - 127.90] |
bson | 45 [+246%] | 42.67 [ 30.45 - 48.13] | 102.22 [ 72.41 - 113.37] | 147.86 [107.70 - 165.23] |
cbor | 26 [+100%] | 29.30 [ 21.86 - 33.01] | 158.47 [116.82 - 182.08] | 185.83 [129.80 - 209.97] |
simd_json | 38 [+192%] | 36.12 [ 24.98 - 49.41] | 330.43 [220.58 - 493.58] | 384.26 [243.10 - 545.29] |
flexbuffers | 44 [+238%] | 383.99 [279.44 - 433.44] | 101.35 [ 75.51 - 112.54] | 545.00 [413.95 - 628.83] |
toml | 37 [+184%] | 469.24 [307.22 - 492.86] | 580.37 [386.81 - 633.13] | 1073.73 [754.72 - 1187.96] |
protobuf | - | - | - | - |
2. MacOs Execution
Algorithm | Size (b) | Ser. (ms) | Deser. (ms) | Ser+Deser.(ms) |
---|---|---|---|---|
postcard (schema) | 3 [ -77%] | 1.68 [ 1.63 - 2.85] | 2.08 [ 1.88 - 2.27] | 4.52 [ 3.64 - 4.85] |
FlatMessage | 51 [+292%] | 1.83 [ 1.81 - 1.85] | 3.93 [ 3.90 - 4.04] | 5.09 [ 5.00 - 5.88] |
FlatMessage (⚠️) | 51 [+292%] | 1.78 [ 1.76 - 1.83] | 2.76 [ 2.66 - 4.52] | 5.92 [ 5.13 - 7.49] |
bincode (schema) | 3 [ -77%] | 3.55 [ 3.52 - 3.62] | 4.12 [ 3.96 - 4.22] | 7.46 [ 7.27 - 7.59] |
rmp (schema) | 13 [ +0%] | 3.76 [ 3.65 - 3.85] | 16.15 [ 15.87 - 16.71] | 20.63 [ 19.79 - 20.94] |
rmp | 26 [+100%] | 4.97 [ 4.76 - 5.11] | 30.33 [ 29.55 - 30.88] | 34.20 [ 33.89 - 35.07] |
json | 38 [+192%] | 24.06 [ 23.90 - 24.74] | 36.92 [ 36.70 - 37.95] | 60.92 [ 60.13 - 62.20] |
bson | 45 [+246%] | 27.89 [ 27.38 - 28.39] | 49.57 [ 49.15 - 51.08] | 81.31 [ 80.06 - 82.29] |
cbor | 26 [+100%] | 17.40 [ 17.26 - 17.79] | 102.34 [101.03 - 104.12] | 121.39 [119.61 - 123.23] |
simd_json | 38 [+192%] | 26.13 [ 25.75 - 26.77] | 193.82 [186.38 - 214.73] | 220.08 [213.59 - 253.01] |
flexbuffers | 44 [+238%] | 161.10 [158.31 - 163.03] | 67.87 [ 66.92 - 69.34] | 234.97 [232.07 - 261.17] |
toml | 37 [+184%] | 195.04 [192.15 - 197.56] | 295.58 [288.06 - 300.80] | 515.11 [499.74 - 539.25] |
protobuf | - | - | - | - |
3. Linux Execution
Algorithm | Size (b) | Ser. (ms) | Deser. (ms) | Ser+Deser.(ms) |
---|---|---|---|---|
postcard (schema) | 3 [ -77%] | 1.90 [ 1.86 - 2.01] | 3.33 [ 3.28 - 3.43] | 4.78 [ 4.72 - 4.87] |
FlatMessage (⚠️) | 51 [+292%] | 2.06 [ 1.67 - 2.31] | 4.35 [ 4.24 - 5.20] | 5.14 [ 4.53 - 6.42] |
FlatMessage | 51 [+292%] | 2.08 [ 1.58 - 2.55] | 4.29 [ 4.19 - 6.00] | 5.23 [ 4.88 - 7.01] |
bincode (schema) | 3 [ -77%] | 2.34 [ 2.30 - 2.75] | 6.08 [ 5.93 - 7.04] | 10.57 [ 10.39 - 12.25] |
rmp (schema) | 13 [ +0%] | 3.99 [ 3.79 - 5.62] | 22.86 [ 22.52 - 27.89] | 28.12 [ 27.63 - 30.23] |
rmp | 26 [+100%] | 5.35 [ 5.28 - 5.50] | 38.55 [ 37.46 - 40.42] | 45.84 [ 44.45 - 52.82] |
json | 38 [+192%] | 24.12 [ 23.71 - 24.78] | 44.71 [ 43.98 - 46.08] | 70.54 [ 68.76 - 104.62] |
bson | 45 [+246%] | 28.20 [ 27.70 - 29.17] | 77.89 [ 76.43 - 79.92] | 108.27 [107.16 - 112.51] |
cbor | 26 [+100%] | 22.64 [ 22.09 - 23.73] | 118.84 [116.84 - 138.67] | 137.75 [135.90 - 145.47] |
simd_json | 38 [+192%] | 21.20 [ 20.89 - 28.28] | 128.36 [124.29 - 133.47] | 158.68 [153.74 - 184.81] |
flexbuffers | 44 [+238%] | 176.53 [169.48 - 187.20] | 79.01 [ 77.30 - 110.28] | 288.10 [279.43 - 292.04] |
toml | 37 [+184%] | 217.34 [213.23 - 248.23] | 343.34 [335.26 - 387.61] | 649.56 [637.36 - 683.45] |
protobuf | - | - | - | - |