The build receives commands as JSON string and deserializes them into objects. This process is highly optimized within TDW.
JSON is known to be slower than other serialization formats. However, on the backend, JSON allows us to rapidly iterate, fix, and create commands. Switching to a different serialization format would take a tremendous amount of time and result in a faster but much more fragile API; we've decided that this is not a good tradeoff.
The test controller sends increasing quantities of the command {"$type": "do_nothing"}
for 1000 iterations. The build responds with an empty frame.
Quantity | Size (bytes) | FPS |
---|---|---|
1 | 25 | 826 |
2 | 50 | 857 |
4 | 100 | 867 |
8 | 200 | 847 |
16 | 400 | 821 |
32 | 800 | 781 |
64 | 1600 | 717 |
128 | 3200 | 662 |
256 | 6400 | 611 |
512 | 12800 | 412 |
1024 | 25600 | 316 |
2048 | 51200 | 186 |
The test controller deserializes a Vector3 and a Quaternion per frame for 5000 frames. The build responds with an empty frame.
Result: 614 FPS
- Follow instructions in the Benchmark document for cloning the repo, downloading the build, etc.
cd path/to/tdw/Python/benchmarking
(replacepath/to
with the actual path)python3 command_deserialization.py
orpython3 struct_deserialization.py
- Run the build
- Wait for the performance benchmark to complete (this might take up to five minutes).
- Compare your results to those listed above