Performance and Size Tests
Introduction
To measure speed, we compare several of the most popular data serialization formats—JSON
, MessagePack
, and Protobuf
—against Encodexx
on a few typical tasks:
- Serializing an object with 10 fields
- Serializing an array of numeric objects
- Serializing deeply nested objects (10 levels deep)
Each serialization run is executed 40 times, measuring the expected execution time and standard deviation.
System Specifications
- CPU: Intel(R) Core(TM) Ultra 7 155H
- RAM: 16 GB
- OS: Windows 11
Data Generation
The data was pre-generated and is not included in the performance measurements.
export const dataTest1 = { name: "Name", info: { createdAt: new Date(), updatedAt: new Date(), createdBy: "admin", }, logs: Array.from({ length: 300000 }, (_, i) => ({ id: i, createdAt: new Date(), updatedAt: new Date(), message: String(Math.random()), })), };
export const dataTest2 = { chart1: Array.from({ length: 5000000 }, (_, i) => ({ id: i, xValue: Math.random() * 1000, yValue: Math.random() * 1000, })),};
export const dataTest3 = { info: { createdAt: new Date(), updatedAt: new Date(), createdBy: Array.from({ length: 30000 }, () => ({ name: "admin", email: { address: { primary: { value: { text: { content: { value: { textArr: Array.from({ length: 10 }, () => String(Math.random())), }, }, }, }, }, }, }, })), },};
Test Code
Test code is available in the repository on GitHub
Serialization Results
Test 1 Results
Performed 80 runs
Format | E(x) (ms) | σ (ms) | Size (KB) |
---|---|---|---|
Encodexx | 222.8942 | 22.1144 | 12 011 |
Protobuf | 465.2401 | 55.8252 | 11 409 |
MessagePack | 741.6133 | 137.0992 | 22 214 |
JSON | 937.8181 | 60.7893 | 36 005 |
Test 2 Results
Performed 40 runs
Format | E(x) (ms) | σ (ms) | Size (KB) |
---|---|---|---|
Encodexx | 330.0305 | 37.8702 | 97 657 |
Protobuf | 9820.2422 | 179.0492 | 120 006 |
MessagePack | 1974.9417 | 447.7696 | 200 066 |
JSON | 2793.5002 | 56.6046 | 337 412 |
Test 3 Results
Performed 80 runs
Format | E(x) (ms) | σ (ms) | Size (KB) |
---|---|---|---|
Encodexx | 152.7940 | 32.2443 | 6 905 |
Protobuf | 297.3649 | 42.3469 | 6 846 |
MessagePack | 84.3228 | 27.2956 | 7 843 |
JSON | 45.5487 | 10.1584 | 9 278 |
Deserialization Results
Test 1 Results
Performed 80 runs
Format | E(x) (ms) | σ (ms) |
---|---|---|
Encodexx | 359.2488 | 47.0988 |
Protobuf | 241.4967 | 29.3344 |
MessagePack | 635.8366 | 135.4168 |
JSON | 357.9023 | 38.7211 |
Test 2 Results
Performed 40 runs
Format | E(x) (ms) | σ (ms) |
---|---|---|
Encodexx | 1167.3007 | 180.1760 |
Protobuf | 1420.4842 | 341.2971 |
MessagePack | 2174.5072 | 556.5641 |
JSON | 4289.6828 | 241.2971 |
Test 3 Results
Performed 80 runs
Format | E(x) (ms) | σ (ms) |
---|---|---|
Encodexx | 82.7940 | 17.4066 |
Protobuf | 63.6465 | 19.1032 |
MessagePack | 156.7593 | 56.4024 |
JSON | 71.1563 | 37.5730 |
Conclusions
As seen, Encodexx
demonstrates excellent performance in both serialization and deserialization speed as well as data size. It also offers outstanding support for TypeScript and custom data types.