Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and benchmark for block_data SDP serialization (JSON/binary) #119

Merged
merged 3 commits into from
Aug 24, 2023

Conversation

vasdommes
Copy link
Collaborator

@vasdommes vasdommes commented Aug 17, 2023

  • Added a simple test and benchmark for block_data serialization to unit tests.
  • Some refactoring in tests - extracted common DIFF functions used in both unit and integration tests.

block_data_serialization.test writes block_data (constraint matrix B, constraint vector c and blilinear bases) to stringstream and then reads them back.
On my laptop, the benchmarking results are kind of unstable, but generally show ~20x-30x speedup for binary format compared to JSON (see #79).

Note that in real applications the expected bottlneck is disk IO, so one can expect up to ~2.4x speedup.
I observed such numbers for writing sdp in small end-to-end tests, but they should be taken with a grain of salt. I haven't benchmarked any big problem.

Note that, by default, Catch2 framework does not run test cases marked by [!benchmark]
To run benchmark, run unit_tests as follows:

./build/unit_tests [!benchmark]

Catch2 by default uses 100 samples (i.e. runs each benchmark 100 times) and prints detailed statistics.
For a simple and fast output, you can run, e.g.,

./build/unit_tests [!benchmark] --benchmark-samples 10 --benchmark-no-analysis 

More information on Catch2 benchmarks and command-line options:
https://github.com/catchorg/Catch2/blob/devel/docs/benchmarks.md
https://github.com/catchorg/Catch2/blob/devel/docs/command-line.md

…bin and .json

You can run benchmark as
./build/unit_tests [!benchmark] --benchmark-samples 10 --benchmark-no-analysis

On my laptop, binary format is ~20x-30x faster than JSON for combined write+read to an in-memory stringstream.
If disk IO is a bottleneck (which sounds more realistic), one can expect more moderate speedup, ~2.4x because binary format is more compact than JSON.

This is a part of davidsd#111 Benchmarks for reading/writing sdp.zip.
@vasdommes vasdommes requested a review from davidsd August 17, 2023 04:58
@vasdommes vasdommes self-assigned this Aug 17, 2023
@vasdommes vasdommes merged commit 9c4bc66 into davidsd:master Aug 24, 2023
@vasdommes vasdommes deleted the sdp-benchmark branch August 24, 2023 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant