Large Vectors
This benchmarks checks to see how well a structure containing variant fields can be serialized and deserialized. The fields are instantiated with different values, as follows:
v1
is initialized toMyVariant::U32(0x12345)
v2
is initialized toMyVariant::U64(0x1234567890)
v3
is initialized toMyVariant::String(String::from("Hello, World!"))
v4
is initialized toMyVariant::Vector(vec![1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 100, 200, 300, 400, 500, 1000, 2000, 3000, 4000, 5000])
v5
is initialized toMyVariant::StringVector(vec![String::from("Hello"), String::from("World"), String::from("This"), String::from("is"), String::from("a"), String::from("test")])
v6
is initialized toMyVariant::SimpleVariant
v7
is initialized toMyVariant::U32(0)
v8
is initialized toMyVariant::U64(100)
v9
is initialized toNone
v10
is initialized toSome(MyVariant::String(String::from("Hello, World! Testing a variant in a option field").repeat(100)))
#![allow(unused)] fn main() { enum MyVariant { U32(u32), U64(u64), String(String), Vector(Vec<u32>), StringVector(Vec<String>), SimpleVariant, } pub struct VariantFields { v1: MyVariant, v2: MyVariant, v3: MyVariant, v4: MyVariant, v5: MyVariant, v6: MyVariant, v7: MyVariant, v8: MyVariant, v9: Option<MyVariant>, v10: Option<MyVariant>, } }
Test specs
- Iterations:
k = 10
- Serialization and deserialization repetitions / iteration:
n = 50000
- Data size:
5048
bytes - Protobuf: Not Supported (directly via prost crate)
Results
1. Windows Execution
Algorithm | Size (b) | Ser. (ms) | Deser. (ms) | Ser+Deser.(ms) |
---|---|---|---|---|
FlatMessage (⚠️) | 5196 [ +2%] | 5.24 [ 4.69 - 5.93] | 23.26 [ 22.27 - 24.29] | 30.12 [ 27.53 - 37.23] |
FlatMessage | 5196 [ +2%] | 5.61 [ 5.09 - 9.37] | 32.81 [ 31.98 - 33.72] | 39.84 [ 36.56 - 43.92] |
postcard (schema) | 4996 [ -2%] | 9.40 [ 8.76 - 13.15] | 36.81 [ 34.21 - 38.92] | 48.57 [ 43.86 - 50.31] |
bincode (schema) | 5009 [ -1%] | 8.77 [ 8.31 - 10.77] | 40.38 [ 37.87 - 45.36] | 52.20 [ 47.74 - 54.20] |
rmp (schema) | 5075 [ +0%] | 8.97 [ 8.28 - 9.84] | 47.98 [ 44.86 - 64.15] | 60.30 [ 57.04 - 62.03] |
rmp | 5106 [ +1%] | 10.37 [ 9.55 - 12.18] | 54.21 [ 51.39 - 56.13] | 68.88 [ 64.08 - 70.95] |
cbor | 5109 [ +1%] | 24.55 [ 22.84 - 26.80] | 129.43 [120.49 - 149.67] | 156.10 [145.30 - 160.28] |
bson | 5426 [ +7%] | 45.29 [ 42.39 - 46.29] | 114.96 [111.40 - 120.21] | 178.18 [168.74 - 224.70] |
simd_json | 5211 [ +3%] | 28.53 [ 27.50 - 30.39] | 169.81 [161.40 - 176.34] | 204.18 [190.35 - 213.70] |
flexbuffers | 5259 [ +4%] | 135.43 [128.13 - 155.44] | 93.74 [ 85.96 - 98.08] | 240.00 [222.26 - 260.34] |
json | 5211 [ +3%] | 130.93 [124.74 - 133.99] | 123.41 [118.38 - 135.17] | 257.43 [248.58 - 268.54] |
toml | 5216 [ +3%] | 703.33 [684.13 - 724.79] | 730.39 [694.26 - 742.67] | 1465.12 [1394.57 - 1499.54] |
protobuf | - | - | - | - |
2. MacOs Execution
Algorithm | Size (b) | Ser. (ms) | Deser. (ms) | Ser+Deser.(ms) |
---|---|---|---|---|
FlatMessage (⚠️) | 5196 [ +2%] | 12.84 [ 8.94 - 13.48] | 16.29 [ 14.69 - 16.81] | 24.15 [ 22.66 - 24.94] |
FlatMessage | 5196 [ +2%] | 13.48 [ 9.35 - 13.68] | 25.64 [ 24.55 - 26.46] | 33.67 [ 32.72 - 34.72] |
postcard (schema) | 4996 [ -2%] | 10.72 [ 10.51 - 11.08] | 27.78 [ 27.40 - 29.04] | 38.40 [ 38.16 - 40.01] |
bincode (schema) | 5009 [ -1%] | 9.96 [ 9.90 - 10.03] | 30.25 [ 30.03 - 30.73] | 40.54 [ 40.37 - 41.28] |
rmp (schema) | 5075 [ +0%] | 10.40 [ 10.39 - 10.58] | 37.87 [ 37.47 - 38.66] | 48.61 [ 47.58 - 68.96] |
rmp | 5106 [ +1%] | 11.52 [ 11.50 - 12.02] | 42.37 [ 41.83 - 43.24] | 54.39 [ 53.97 - 55.11] |
cbor | 5109 [ +1%] | 22.10 [ 22.06 - 22.58] | 97.05 [ 96.02 - 102.05] | 120.43 [119.48 - 124.76] |
bson | 5426 [ +7%] | 38.79 [ 38.68 - 39.01] | 82.71 [ 81.96 - 101.91] | 124.26 [123.67 - 126.39] |
simd_json | 5211 [ +3%] | 38.11 [ 38.03 - 38.91] | 120.43 [118.82 - 123.70] | 158.85 [158.38 - 163.32] |
flexbuffers | 5259 [ +4%] | 97.97 [ 96.15 - 101.65] | 66.20 [ 65.83 - 66.95] | 167.95 [166.90 - 174.09] |
json | 5211 [ +3%] | 100.08 [100.01 - 102.47] | 85.69 [ 85.15 - 101.58] | 185.64 [185.34 - 190.29] |
toml | 5216 [ +3%] | 778.50 [774.68 - 803.87] | 696.37 [690.99 - 736.16] | 1489.91 [1479.77 - 1747.68] |
protobuf | - | - | - | - |
3. Linux Execution
Algorithm | Size (b) | Ser. (ms) | Deser. (ms) | Ser+Deser.(ms) |
---|---|---|---|---|
FlatMessage (⚠️) | 5196 [ +2%] | 6.24 [ 4.82 - 6.75] | 13.20 [ 10.72 - 19.85] | 19.80 [ 16.45 - 32.59] |
FlatMessage | 5196 [ +2%] | 5.03 [ 4.58 - 6.67] | 22.95 [ 18.64 - 26.22] | 28.88 [ 24.86 - 32.44] |
postcard (schema) | 4996 [ -2%] | 8.70 [ 8.02 - 14.57] | 26.86 [ 25.57 - 44.28] | 36.57 [ 34.88 - 53.06] |
bincode (schema) | 5009 [ -1%] | 9.21 [ 8.75 - 12.83] | 36.15 [ 31.15 - 42.31] | 48.27 [ 42.28 - 69.02] |
rmp (schema) | 5075 [ +0%] | 8.18 [ 7.70 - 15.05] | 41.17 [ 38.08 - 66.74] | 52.07 [ 48.35 - 66.61] |
rmp | 5106 [ +1%] | 9.28 [ 8.91 - 11.28] | 47.16 [ 44.65 - 50.59] | 59.07 [ 56.07 - 85.17] |
cbor | 5109 [ +1%] | 24.83 [ 22.68 - 27.00] | 114.13 [108.59 - 123.74] | 141.75 [135.40 - 147.29] |
bson | 5426 [ +7%] | 48.16 [ 44.99 - 57.07] | 103.61 [ 98.11 - 135.86] | 158.63 [151.21 - 208.65] |
simd_json | 5211 [ +3%] | 27.01 [ 25.51 - 28.63] | 145.97 [138.55 - 148.97] | 180.56 [171.26 - 204.58] |
flexbuffers | 5259 [ +4%] | 118.13 [114.57 - 175.30] | 82.46 [ 79.07 - 111.77] | 212.49 [203.93 - 226.69] |
json | 5211 [ +3%] | 138.60 [133.35 - 150.30] | 102.57 [ 98.12 - 112.70] | 240.33 [231.69 - 285.45] |
toml | 5216 [ +3%] | 580.61 [574.53 - 625.95] | 634.01 [613.55 - 684.37] | 1248.94 [1196.76 - 1293.67] |
protobuf | - | - | - | - |