Publish benchmarks on the Actions tab (#117)

This commit is contained in:
liuzicheng1987
2024-06-08 19:14:03 +02:00
committed by GitHub
parent 108efb93cb
commit 5f0d0e6e7e
8 changed files with 152 additions and 97 deletions
-51
View File
@@ -1,51 +0,0 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
+18 -10
View File
@@ -1,4 +1,4 @@
name: test
name: linux-clang
on: [ push, pull_request ]
@@ -29,7 +29,7 @@ jobs:
clang --version
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build -j 4
- name: Run tests
- name: Run tess
run: |
./build/tests/bson/reflect-cpp-bson-tests
./build/tests/cbor/reflect-cpp-cbor-tests
@@ -41,11 +41,19 @@ jobs:
./build/tests/yaml/reflect-cpp-yaml-tests
- name: Run benchmarks
run: |
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write
echo '# Benchmarks' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks across different formats' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks for JSON' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
+18 -9
View File
@@ -1,4 +1,4 @@
name: test
name: linux-gcc
on: [ push, pull_request ]
@@ -34,11 +34,20 @@ jobs:
./build/tests/yaml/reflect-cpp-yaml-tests
- name: Run benchmarks
run: |
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write
echo '# Benchmarks' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks across different formats' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks for JSON' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
+16 -9
View File
@@ -1,4 +1,4 @@
name: test
name: macos-clang-arm
on: [ push, pull_request ]
@@ -36,11 +36,18 @@ jobs:
./build/tests/yaml/reflect-cpp-yaml-tests
- name: Run benchmarks
run: |
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write
echo '# Benchmarks' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks across different formats' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks for JSON' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
+16 -9
View File
@@ -1,4 +1,4 @@
name: test
name: macos-clang-x64
on: [ push, pull_request ]
@@ -33,11 +33,18 @@ jobs:
./build/tests/yaml/reflect-cpp-yaml-tests
- name: Run benchmarks
run: |
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write
echo '# Benchmarks' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks across different formats' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=licenses_write >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=person_write >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '## Benchmarks for JSON' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=person_read >> $GITHUB_STEP_SUMMARY
./build/benchmarks/json/reflect-cpp-json-benchmarks --benchmark_filter=canada >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
+16 -9
View File
@@ -1,4 +1,4 @@
name: test
name: windows-msvc
on: [ push, pull_request ]
@@ -29,11 +29,18 @@ jobs:
.\build\tests\yaml\Release\reflect-cpp-yaml-tests.exe
- name: Run benchmarks
run: |
.\build\benchmarks\json\Release\reflect-cpp-json-benchmarks.exe --benchmark_filter=canada
.\build\benchmarks\json\Release\reflect-cpp-json-benchmarks.exe --benchmark_filter=person_read
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=canada_read
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=canada_write
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=licenses_read
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=licenses_write
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=person_read
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=person_write
echo '# Benchmarks' >> $env:GITHUB_STEP_SUMMARY
echo '## Benchmarks across different formats' >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=canada_read >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=canada_write >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=licenses_read >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=licenses_write >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=person_read >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\all\Release\reflect-cpp-all-format-benchmarks.exe --benchmark_filter=person_write >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
echo '## Benchmarks for JSON' >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\json\Release\reflect-cpp-json-benchmarks.exe --benchmark_filter=canada >> $env:GITHUB_STEP_SUMMARY
.\build\benchmarks\json\Release\reflect-cpp-json-benchmarks.exe --benchmark_filter=person_read >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
+10
View File
@@ -476,6 +476,16 @@ For a more in-depth theoretical discussions of these topics, the following books
Click [here](https://github.com/getml/reflect-cpp/tree/main/docs).
## Benchmarks
reflect-cpp conducts continuuous benchmarking across different operating systems, compilers and architectures
and publishes the results on its [Actions tab](https://github.com/getml/reflect-cpp/actions).
Refer to the [benchmarks folder](https://github.com/getml/reflect-cpp/tree/main/benchmarks) for details.
The benchmarks show that reflect-cpp is not only very convenient, but also one the fastest JSON libraries for C++.
It is faster than RapidJSON and about 10 times faster than nlohmann/json. It can be even faster than that,
if you choose to use a different format supported by reflect-cpp, such as msgpack.
## Installation
The following compilers are supported:
+58
View File
@@ -0,0 +1,58 @@
# Benchmarks
reflect-cpp conducts continuuous benchmarking through its [Github Actions](https://github.com/getml/reflect-cpp/actions) pipelines for different compilers, operating systems
and architectures. Currently, we benchmark the following:
1. How reflect-cpp's JSON parser compares to other JSON libraries for C or C++
2. How the different formats supported by reflect-cpp compare to each other
## Viewing the benchmark results
To view the benchmark results, go to the [Actions tab](https://github.com/getml/reflect-cpp/actions)
of this Github repository, click on a recent run you are interested in and scroll down to view the summary.
## Running the benchmark results on your own machine
Make sure that you have vcpkg installed. Refer to the README in the root folder of
this repository to learn how to install vcpkg.
To compile the benchmarks, do the following:
```bash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DREFLECTCPP_BUILD_BENCHMARKS=ON
cmake --build build -j 4 # gcc, clang
cmake --build build --config Release -j 4 # MSVC
```
To run the benchmarks, do the following:
```
./build/benchmarks/json/reflect-cpp-json-benchmarks
./build/benchmarks/all/reflect-cpp-all-format-benchmarks
```
Note that the benchmarks are based on Google Benchmarks. You can use the `--benchmark-filter` flag
to only run some of the benchmarks:
```
./build/benchmarks/all/reflect-cpp-all-format-benchmarks --benchmark_filter=canada_read
```
## Results summary
### How reflect-cpp compares to other JSON libraries
- reflect-cpp is currently slightly slower than the fastest JSON libraries for C and C++, namely simdJSON and yyjson. We are working on getting that overhead down to zero.
- reflect-cpp is consistently faster than RapidJSON, usually about twice as fast.
- reflect-cpp is consistently about 10 times faster than nlohmann/json, which is undeniably the most popular JSON library for C++.
In summary, it is fair to say that reflect-cpp is among the fastest JSON libraries for C++. It also considerably more convenient: If you look at the benchmark code, you will find that you can implement the serialization and deserialization using a single line of code with reflect-cpp, but you will need about 50-90 lines of code to do the same with other libraries (including nlohmann/json).
### How the different formats supported by reflect-cpp compare to each other
- flexbuffers and msgpack are the fastest two formats supported by reflect-cpp. They are particularly fast on datasets with a lot of numerical data, such as *canada*. flexbuffers is usually the fastest at reading data and msgpack is the fastest at writing.
- JSON is surprisingly fast. This is because reflect-cpp's JSON parser is built on top of yyjson, arguably the fastest JSON library for C or C++.
- The performance of CBOR is disappointing. We have tried swapping out the underlying library, TinyCBOR, for libcbor, but the results are similar.
- TOML and YAML are very slow when compared to the other formats. To be fair, these formats emphasize readability rather than speed.
In summary, if you are looking for a format that emphasizes speed, msgpack is probably your best bet. Not only does it perform very well on our benchmarks, but there are also many high-quality implementations in other languages. If you are looking for a good trade-off between speed and readability, you should probably just stick with JSON.