mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Compare commits
225 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e1d07ee86 | |||
| 9de1b45e30 | |||
| 7a73230459 | |||
| 667f488c2c | |||
| e6c90b8efb | |||
| 7c450fbb70 | |||
| 4e1e002cb0 | |||
| de196dd7a3 | |||
| 08cb8dd81c | |||
| 57d54792ba | |||
| 79879802f9 | |||
| fbe955e9a4 | |||
| a49ac04046 | |||
| 49c7654a70 | |||
| 3e777c1759 | |||
| a410c723c8 | |||
| f91a1ae07e | |||
| c3954b1fb8 | |||
| ce74ece545 | |||
| dd4dce848e | |||
| e8f370b085 | |||
| 645033a8c8 | |||
| 3b5ceeb80d | |||
| 82433a67f9 | |||
| 8c1bfe782b | |||
| 730939f01c | |||
| b169dc2ea7 | |||
| 1aa1d537fe | |||
| c122462278 | |||
| b6b338bea9 | |||
| f72636b5b0 | |||
| f6a2bac11b | |||
| e4ddc5446b | |||
| e0e0aa9e7b | |||
| 9f0a2e0e86 | |||
| 203c03e90b | |||
| 6698eb96b9 | |||
| 30f7de387c | |||
| e0788507fe | |||
| e4740c87fb | |||
| 5beef701e7 | |||
| c6f9c93c33 | |||
| 3a93e45dd1 | |||
| 6db8ceb46c | |||
| 23651f0d41 | |||
| 7e1893db42 | |||
| b4b1927b0f | |||
| e275589832 | |||
| 69ee84973a | |||
| 76bed68ec3 | |||
| 003d970cd2 | |||
| 4aaf3f030c | |||
| 2763f7e719 | |||
| 39035c39be | |||
| ac179ff40f | |||
| b41bece32c | |||
| 9cb0c5f92d | |||
| 1dec7b04fe | |||
| c6eb6f98b8 | |||
| 1b01969bda | |||
| 17f3148ac7 | |||
| 35b4a48e99 | |||
| c0d18452fc | |||
| e5c9a310cf | |||
| 6d308a08c5 | |||
| 9e477ddb00 | |||
| b7c4d1eeef | |||
| 4a2f10ebcf | |||
| 41cb909604 | |||
| 91908ade4d | |||
| 9a32c48098 | |||
| d996ffc494 | |||
| d56fdc3d04 | |||
| 1dce4fed6e | |||
| cae5e5342f | |||
| 4e609aa955 | |||
| d28e5534d9 | |||
| 3bd8b0b575 | |||
| af4ff7cc33 | |||
| c9179ad81d | |||
| d6b5124c88 | |||
| 64b62fd3b3 | |||
| cebe3fb299 | |||
| ed7343f7f2 | |||
| 35158257c6 | |||
| b935ce2e06 | |||
| 4afe7565b4 | |||
| 6bed34ad61 | |||
| 0ad52a7e22 | |||
| aa52cf6868 | |||
| cd11838e5f | |||
| c31157bafe | |||
| 419b7b2ce8 | |||
| ca3f3cc49d | |||
| d3f0e2afb3 | |||
| eac3832ec0 | |||
| db19c7675f | |||
| d036fdf919 | |||
| fc0934755a | |||
| de4deb8c4e | |||
| ba46616cbc | |||
| a552638373 | |||
| e30123d58f | |||
| b7dee3e9c8 | |||
| 717d0c24a6 | |||
| 40813752f4 | |||
| 19902abaf8 | |||
| 06643fc9f5 | |||
| 0fa68d8930 | |||
| cc98358453 | |||
| 5f0b35b2c5 | |||
| bd0f5e9322 | |||
| cb0e4b23c7 | |||
| d83e69d977 | |||
| f657516a7e | |||
| 8d29c5f931 | |||
| eeac91579c | |||
| e5a4b8b81b | |||
| 7b8f775893 | |||
| c6ef2105ab | |||
| e681234e45 | |||
| eb93b98d6a | |||
| 7d887fdc1e | |||
| 9d405a5df4 | |||
| 18c003e8bf | |||
| ec4316aa84 | |||
| b79261eebc | |||
| 47a62db559 | |||
| 01645cbd69 | |||
| 3dbecab494 | |||
| 5c590b8434 | |||
| 2dac3705d2 | |||
| 774999ee95 | |||
| c906f864d7 | |||
| 68e3c4f984 | |||
| b08818fab9 | |||
| 33f73b577c | |||
| 30422cfdd3 | |||
| b085b56e32 | |||
| ea3d4e7ce5 | |||
| bea1483cde | |||
| 90efd79055 | |||
| 7e646efd0f | |||
| eb849662c0 | |||
| f146294a85 | |||
| 374de826ab | |||
| 1fd3e32051 | |||
| e607958a7b | |||
| 0f068fb7c4 | |||
| b991a4c7f3 | |||
| 5b99a75ae1 | |||
| 1ba73b9e6b | |||
| cfe3adb599 | |||
| be6052bcdc | |||
| ca8e21583c | |||
| 1c01fc35eb | |||
| ce38fe7bea | |||
| 6cd04aa858 | |||
| 03f7396d50 | |||
| a4803d50c5 | |||
| 40cba172ed | |||
| 3ba221eb8e | |||
| 8bc12fe7cb | |||
| 34bb2079e7 | |||
| 7ca016652e | |||
| 13ab123daf | |||
| f54bd69b5b | |||
| 16e8db1f17 | |||
| eb0ae041e3 | |||
| 893e613faa | |||
| 714f0ba222 | |||
| 19c3b1315a | |||
| f44a53271d | |||
| d90714e8df | |||
| c7fd7353a8 | |||
| 05f15d88b6 | |||
| d7d81c7152 | |||
| 73b510225f | |||
| 5d2eca2363 | |||
| 939b6b854a | |||
| 4f8bdf517a | |||
| 369f66be35 | |||
| 8a75dbf719 | |||
| 1032f70ddf | |||
| 16e2323153 | |||
| 2ec23bdf37 | |||
| 4fb09824bf | |||
| ad1cd6a2ce | |||
| a27367210a | |||
| efe9761f80 | |||
| 0b75de12ef | |||
| af5c8175b4 | |||
| 8df32cea33 | |||
| e4150443ca | |||
| d539781cf3 | |||
| 2bbab7d892 | |||
| 729c35c0f8 | |||
| 2abcc35031 | |||
| 85b910814e | |||
| c1dffac28c | |||
| 911b06186b | |||
| be9d5d4e31 | |||
| b32d66e7b6 | |||
| 939bfc701a | |||
| 9c470822a1 | |||
| 59195bd5dc | |||
| ef8c2c434e | |||
| 5ec85197f8 | |||
| 8eed8f5155 | |||
| 48f5e8b6c3 | |||
| 0a2da45794 | |||
| a79bbd63a3 | |||
| c667b0cfdf | |||
| b3a22bea56 | |||
| 6ca6ee5a6f | |||
| 78cff7518b | |||
| d0821adf0e | |||
| 461bc4c47e | |||
| 99406266b1 | |||
| a6576f1d09 | |||
| 95b4870e20 | |||
| 5607253be5 | |||
| 94563328c4 | |||
| ddf610125f | |||
| b6cce3d744 |
+6
-6
@@ -15,29 +15,29 @@ environment:
|
|||||||
- job_name: VS2019
|
- job_name: VS2019
|
||||||
CMAKE_ARGS: -A %Platform%
|
CMAKE_ARGS: -A %Platform%
|
||||||
- job_name: VS2019ARM
|
- job_name: VS2019ARM
|
||||||
CMAKE_ARGS: -A ARM64 -DCMAKE_CROSSCOMPILING=1 -D SIMDJSON_GOOGLE_BENCHMARKS=OFF # Does Google Benchmark builds under VS ARM?
|
CMAKE_ARGS: -A ARM64 -DSIMDJSON_DEVELOPER_MODE=ON -DCMAKE_CROSSCOMPILING=1 -D SIMDJSON_GOOGLE_BENCHMARKS=OFF # Does Google Benchmark builds under VS ARM?
|
||||||
- job_name: VS2017 (Static, No Threads)
|
- job_name: VS2017 (Static, No Threads)
|
||||||
image: Visual Studio 2017
|
image: Visual Studio 2017
|
||||||
CMAKE_ARGS: -A %Platform% -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_ENABLE_THREADS=OFF
|
CMAKE_ARGS: -A %Platform% -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_ENABLE_THREADS=OFF
|
||||||
CTEST_ARGS: -LE explicitonly
|
CTEST_ARGS: -LE explicitonly
|
||||||
- job_name: VS2019 (Win32)
|
- job_name: VS2019 (Win32)
|
||||||
platform: Win32
|
platform: Win32
|
||||||
CMAKE_ARGS: -A %Platform% -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_ENABLE_THREADS=ON # This should be the default. Testing anyway.
|
CMAKE_ARGS: -A %Platform% -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=ON -DSIMDJSON_ENABLE_THREADS=ON # This should be the default. Testing anyway.
|
||||||
CTEST_ARGS: -LE explicitonly
|
CTEST_ARGS: -LE explicitonly
|
||||||
- job_name: VS2019 (Win32, No Exceptions)
|
- job_name: VS2019 (Win32, No Exceptions)
|
||||||
platform: Win32
|
platform: Win32
|
||||||
CMAKE_ARGS: -A %Platform% -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_ENABLE_THREADS=ON -DSIMDJSON_EXCEPTIONS=OFF
|
CMAKE_ARGS: -A %Platform% -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=ON -DSIMDJSON_ENABLE_THREADS=ON -DSIMDJSON_EXCEPTIONS=OFF
|
||||||
CTEST_ARGS: -LE explicitonly
|
CTEST_ARGS: -LE explicitonly
|
||||||
- job_name: VS2015
|
- job_name: VS2015
|
||||||
image: Visual Studio 2015
|
image: Visual Studio 2015
|
||||||
CMAKE_ARGS: -A %Platform% -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_ENABLE_THREADS=OFF
|
CMAKE_ARGS: -A %Platform% -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_ENABLE_THREADS=OFF
|
||||||
CTEST_ARGS: -LE explicitonly
|
CTEST_ARGS: -LE explicitonly
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake --version
|
- cmake --version
|
||||||
- cmake %CMAKE_ARGS% --parallel ..
|
- cmake %CMAKE_ARGS% ..
|
||||||
- cmake -LH ..
|
- cmake -LH ..
|
||||||
- cmake --build . --config %Configuration% --verbose --parallel
|
- cmake --build . --config %Configuration% --verbose --parallel
|
||||||
|
|
||||||
|
|||||||
+22
-22
@@ -11,7 +11,7 @@ executors:
|
|||||||
environment:
|
environment:
|
||||||
CXX: g++-8
|
CXX: g++-8
|
||||||
CC: gcc-8
|
CC: gcc-8
|
||||||
BUILD_FLAGS:
|
CMAKE_BUILD_FLAGS:
|
||||||
CTEST_FLAGS: --output-on-failure
|
CTEST_FLAGS: --output-on-failure
|
||||||
|
|
||||||
gcc9:
|
gcc9:
|
||||||
@@ -20,7 +20,7 @@ executors:
|
|||||||
environment:
|
environment:
|
||||||
CXX: g++-9
|
CXX: g++-9
|
||||||
CC: gcc-9
|
CC: gcc-9
|
||||||
BUILD_FLAGS:
|
CMAKE_BUILD_FLAGS:
|
||||||
CTEST_FLAGS: --output-on-failure
|
CTEST_FLAGS: --output-on-failure
|
||||||
|
|
||||||
gcc10:
|
gcc10:
|
||||||
@@ -29,7 +29,7 @@ executors:
|
|||||||
environment:
|
environment:
|
||||||
CXX: g++-10
|
CXX: g++-10
|
||||||
CC: gcc-10
|
CC: gcc-10
|
||||||
BUILD_FLAGS:
|
CMAKE_BUILD_FLAGS:
|
||||||
CTEST_FLAGS: --output-on-failure
|
CTEST_FLAGS: --output-on-failure
|
||||||
|
|
||||||
clang10:
|
clang10:
|
||||||
@@ -38,7 +38,7 @@ executors:
|
|||||||
environment:
|
environment:
|
||||||
CXX: clang++-10
|
CXX: clang++-10
|
||||||
CC: clang-10
|
CC: clang-10
|
||||||
BUILD_FLAGS:
|
CMAKE_BUILD_FLAGS:
|
||||||
CTEST_FLAGS: --output-on-failure
|
CTEST_FLAGS: --output-on-failure
|
||||||
|
|
||||||
clang9:
|
clang9:
|
||||||
@@ -47,7 +47,7 @@ executors:
|
|||||||
environment:
|
environment:
|
||||||
CXX: clang++-9
|
CXX: clang++-9
|
||||||
CC: clang-9
|
CC: clang-9
|
||||||
BUILD_FLAGS:
|
CMAKE_BUILD_FLAGS:
|
||||||
CTEST_FLAGS: --output-on-failure
|
CTEST_FLAGS: --output-on-failure
|
||||||
|
|
||||||
clang6:
|
clang6:
|
||||||
@@ -56,7 +56,7 @@ executors:
|
|||||||
environment:
|
environment:
|
||||||
CXX: clang++-6.0
|
CXX: clang++-6.0
|
||||||
CC: clang-6.0
|
CC: clang-6.0
|
||||||
BUILD_FLAGS:
|
CMAKE_BUILD_FLAGS:
|
||||||
CTEST_FLAGS: --output-on-failure
|
CTEST_FLAGS: --output-on-failure
|
||||||
|
|
||||||
# Reusable test commands (and initializer for clang 6)
|
# Reusable test commands (and initializer for clang 6)
|
||||||
@@ -88,13 +88,13 @@ commands:
|
|||||||
steps:
|
steps:
|
||||||
- cmake_prep
|
- cmake_prep
|
||||||
- dependency_restore
|
- dependency_restore
|
||||||
- run: cmake $CMAKE_FLAGS -DCMAKE_INSTALL_PREFIX:PATH=destination -B build .
|
- run: cmake -DSIMDJSON_DEVELOPER_MODE=ON $CMAKE_FLAGS -DCMAKE_INSTALL_PREFIX:PATH=destination -B build .
|
||||||
- dependency_cache # dependencies are produced in the configure step
|
- dependency_cache # dependencies are produced in the configure step
|
||||||
|
|
||||||
cmake_build:
|
cmake_build:
|
||||||
steps:
|
steps:
|
||||||
- cmake_build_cache
|
- cmake_build_cache
|
||||||
- run: cmake --build build
|
- run: cmake --build build
|
||||||
|
|
||||||
cmake_test:
|
cmake_test:
|
||||||
steps:
|
steps:
|
||||||
@@ -129,7 +129,7 @@ commands:
|
|||||||
steps:
|
steps:
|
||||||
- cmake_build_cache
|
- cmake_build_cache
|
||||||
- run: |
|
- run: |
|
||||||
cmake --build build --target checkperf &&
|
cmake -DSIMDJSON_ENABLE_DOM_CHECKPERF=ON --build build --target checkperf &&
|
||||||
cd build &&
|
cd build &&
|
||||||
ctest --output-on-failure -R checkperf
|
ctest --output-on-failure -R checkperf
|
||||||
|
|
||||||
@@ -164,60 +164,60 @@ jobs:
|
|||||||
gcc10-perftest:
|
gcc10-perftest:
|
||||||
description: Build and run performance tests on GCC 10 and AVX 2 with a cmake static build, this test performance regression
|
description: Build and run performance tests on GCC 10 and AVX 2 with a cmake static build, this test performance regression
|
||||||
executor: gcc10
|
executor: gcc10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_BUILD_STATIC=ON }
|
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DBUILD_SHARED_LIBS=OFF }
|
||||||
steps: [ cmake_perftest ]
|
steps: [ cmake_perftest ]
|
||||||
gcc10:
|
gcc10:
|
||||||
description: Build and run tests on GCC 10 and AVX 2 with a cmake static build
|
description: Build and run tests on GCC 10 and AVX 2 with a cmake static build
|
||||||
executor: gcc10
|
executor: gcc10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON }
|
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF }
|
||||||
steps: [ cmake_test, cmake_install_test, cmake_installed_test_cxx20 ]
|
steps: [ cmake_test, cmake_install_test, cmake_installed_test_cxx20 ]
|
||||||
clang6:
|
clang6:
|
||||||
description: Build and run tests on clang 6 and AVX 2 with a cmake static build
|
description: Build and run tests on clang 6 and AVX 2 with a cmake static build
|
||||||
executor: clang6
|
executor: clang6
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON }
|
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF }
|
||||||
steps: [ cmake_test, cmake_install_test ]
|
steps: [ cmake_test, cmake_install_test ]
|
||||||
clang10:
|
clang10:
|
||||||
description: Build and run tests on clang 10 and AVX 2 with a cmake static build
|
description: Build and run tests on clang 10 and AVX 2 with a cmake static build
|
||||||
executor: clang10
|
executor: clang10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON }
|
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF }
|
||||||
steps: [ cmake_test, cmake_install_test, cmake_installed_test_cxx20 ]
|
steps: [ cmake_test, cmake_install_test, cmake_installed_test_cxx20 ]
|
||||||
# libcpp
|
# libcpp
|
||||||
libcpp-clang10:
|
libcpp-clang10:
|
||||||
description: Build and run tests on clang 10 and AVX 2 with a cmake static build and libc++
|
description: Build and run tests on clang 10 and AVX 2 with a cmake static build and libc++
|
||||||
executor: clang10
|
executor: clang10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_USE_LIBCPP=ON -DSIMDJSON_BUILD_STATIC=ON }
|
environment: { CMAKE_FLAGS: -DSIMDJSON_USE_LIBCPP=ON -DBUILD_SHARED_LIBS=OFF }
|
||||||
steps: [ cmake_test, cmake_install_test, cmake_installed_test_cxx20 ]
|
steps: [ cmake_test, cmake_install_test, cmake_installed_test_cxx20 ]
|
||||||
# sanitize
|
# sanitize
|
||||||
sanitize-gcc10:
|
sanitize-gcc10:
|
||||||
description: Build and run tests on GCC 10 and AVX 2 with a cmake sanitize build
|
description: Build and run tests on GCC 10 and AVX 2 with a cmake sanitize build
|
||||||
executor: gcc10
|
executor: gcc10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, BUILD_FLAGS: "", CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
environment: { CMAKE_FLAGS: -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
||||||
steps: [ cmake_test ]
|
steps: [ cmake_test ]
|
||||||
sanitize-clang10:
|
sanitize-clang10:
|
||||||
description: Build and run tests on clang 10 and AVX 2 with a cmake sanitize build
|
description: Build and run tests on clang 10 and AVX 2 with a cmake sanitize build
|
||||||
executor: clang10
|
executor: clang10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
environment: { CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON -DSIMDJSON_NO_FORCE_INLINING=ON -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
||||||
steps: [ cmake_test ]
|
steps: [ cmake_test ]
|
||||||
threadsanitize-gcc10:
|
threadsanitize-gcc10:
|
||||||
description: Build and run tests on GCC 10 and AVX 2 with a cmake sanitize build
|
description: Build and run tests on GCC 10 and AVX 2 with a cmake sanitize build
|
||||||
executor: gcc10
|
executor: gcc10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE_THREADS=ON, BUILD_FLAGS: "", CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
environment: { CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON -DSIMDJSON_SANITIZE_THREADS=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
||||||
steps: [ cmake_test ]
|
steps: [ cmake_test ]
|
||||||
threadsanitize-clang10:
|
threadsanitize-clang10:
|
||||||
description: Build and run tests on clang 10 and AVX 2 with a cmake sanitize build
|
description: Build and run tests on clang 10 and AVX 2 with a cmake sanitize build
|
||||||
executor: clang10
|
executor: clang10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE_THREADS=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
environment: { CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON -DSIMDJSON_NO_FORCE_INLINING=ON -DSIMDJSON_SANITIZE_THREADS=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
||||||
steps: [ cmake_test ]
|
steps: [ cmake_test ]
|
||||||
# dynamic
|
# dynamic
|
||||||
dynamic-gcc10:
|
dynamic-gcc10:
|
||||||
description: Build and run tests on GCC 10 and AVX 2 with a cmake dynamic build
|
description: Build and run tests on GCC 10 and AVX 2 with a cmake dynamic build
|
||||||
executor: gcc10
|
executor: gcc10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
|
environment: { CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON }
|
||||||
steps: [ cmake_test, cmake_install_test ]
|
steps: [ cmake_test, cmake_install_test ]
|
||||||
dynamic-clang10:
|
dynamic-clang10:
|
||||||
description: Build and run tests on clang 10 and AVX 2 with a cmake dynamic build
|
description: Build and run tests on clang 10 and AVX 2 with a cmake dynamic build
|
||||||
executor: clang10
|
executor: clang10
|
||||||
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
|
environment: { CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON }
|
||||||
steps: [ cmake_test, cmake_install_test ]
|
steps: [ cmake_test, cmake_install_test ]
|
||||||
|
|
||||||
# unthreaded
|
# unthreaded
|
||||||
@@ -262,12 +262,12 @@ jobs:
|
|||||||
sanitize-haswell-gcc10:
|
sanitize-haswell-gcc10:
|
||||||
description: Build and run tests on GCC 10 and AVX 2 with a cmake sanitize build
|
description: Build and run tests on GCC 10 and AVX 2 with a cmake sanitize build
|
||||||
executor: gcc10
|
executor: gcc10
|
||||||
environment: { CXXFLAGS: -march=haswell, CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, BUILD_FLAGS: "", CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
environment: { CXXFLAGS: -march=haswell, CMAKE_FLAGS: -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
||||||
steps: [ cmake_test ]
|
steps: [ cmake_test ]
|
||||||
sanitize-haswell-clang10:
|
sanitize-haswell-clang10:
|
||||||
description: Build and run tests on clang 10 and AVX 2 with a cmake sanitize build
|
description: Build and run tests on clang 10 and AVX 2 with a cmake sanitize build
|
||||||
executor: clang10
|
executor: clang10
|
||||||
environment: { CXXFLAGS: -march=haswell, CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
environment: { CXXFLAGS: -march=haswell, CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON -DSIMDJSON_NO_FORCE_INLINING=ON -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: --output-on-failure -LE explicitonly }
|
||||||
steps: [ cmake_test ]
|
steps: [ cmake_test ]
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
|
|||||||
+20
-58
@@ -1,46 +1,4 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: i386-gcc # we do not support 32-bit systems, but we run tests
|
|
||||||
platform: { os: linux, arch: amd64 }
|
|
||||||
steps:
|
|
||||||
- name: Build and Test
|
|
||||||
image: i386/ubuntu
|
|
||||||
environment:
|
|
||||||
CC: gcc
|
|
||||||
CXX: g++
|
|
||||||
BUILD_FLAGS: -- -j
|
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON
|
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
|
||||||
commands:
|
|
||||||
- scripts/addcmakeppa.sh "$(env -i sh -c '. /etc/os-release; echo $VERSION_CODENAME')"
|
|
||||||
- apt-get install -y g++ cmake gcc git
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake $CMAKE_FLAGS ..
|
|
||||||
- cmake --build . $BUILD_FLAGS
|
|
||||||
- ctest $CTEST_FLAGS
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: i386-clang # we do not support 32-bit systems, but we run tests
|
|
||||||
platform: { os: linux, arch: amd64 }
|
|
||||||
steps:
|
|
||||||
- name: Build and Test
|
|
||||||
image: i386/ubuntu
|
|
||||||
environment:
|
|
||||||
CC: clang-6.0
|
|
||||||
CXX: clang++-6.0
|
|
||||||
BUILD_FLAGS: -- -j
|
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON
|
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
|
||||||
commands:
|
|
||||||
- scripts/addcmakeppa.sh "$(env -i sh -c '. /etc/os-release; echo $VERSION_CODENAME')"
|
|
||||||
- apt-get install -y clang++-6.0 cmake git
|
|
||||||
- mkdir build
|
|
||||||
- cd build
|
|
||||||
- cmake $CMAKE_FLAGS ..
|
|
||||||
- cmake --build . $BUILD_FLAGS
|
|
||||||
- ctest $CTEST_FLAGS
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: gcc9
|
name: gcc9
|
||||||
platform: { os: linux, arch: amd64 }
|
platform: { os: linux, arch: amd64 }
|
||||||
steps:
|
steps:
|
||||||
@@ -50,7 +8,7 @@ steps:
|
|||||||
CC: gcc
|
CC: gcc
|
||||||
CXX: g++
|
CXX: g++
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
||||||
@@ -61,6 +19,7 @@ steps:
|
|||||||
- cmake $CMAKE_FLAGS ..
|
- cmake $CMAKE_FLAGS ..
|
||||||
- cmake --build . $BUILD_FLAGS
|
- cmake --build . $BUILD_FLAGS
|
||||||
- ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
- ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
||||||
|
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation
|
||||||
@@ -77,7 +36,7 @@ steps:
|
|||||||
CC: clang-6.0
|
CC: clang-6.0
|
||||||
CXX: clang++-6.0
|
CXX: clang++-6.0
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
- mkdir build
|
- mkdir build
|
||||||
@@ -85,6 +44,7 @@ steps:
|
|||||||
- cmake $CMAKE_FLAGS ..
|
- cmake $CMAKE_FLAGS ..
|
||||||
- cmake --build . $BUILD_FLAGS
|
- cmake --build . $BUILD_FLAGS
|
||||||
- ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
- ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
||||||
|
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ctest $CTEST_FLAGS -L per_implementation
|
||||||
@@ -100,7 +60,7 @@ steps:
|
|||||||
CC: gcc
|
CC: gcc
|
||||||
CXX: g++
|
CXX: g++
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
||||||
@@ -122,7 +82,7 @@ steps:
|
|||||||
environment:
|
environment:
|
||||||
CC: clang-9
|
CC: clang-9
|
||||||
CXX: clang++-9
|
CXX: clang++-9
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
@@ -142,7 +102,7 @@ steps:
|
|||||||
CC: gcc
|
CC: gcc
|
||||||
CXX: g++
|
CXX: g++
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
||||||
@@ -153,6 +113,7 @@ steps:
|
|||||||
- cmake $CMAKE_FLAGS ..
|
- cmake $CMAKE_FLAGS ..
|
||||||
- cmake --build . $BUILD_FLAGS
|
- cmake --build . $BUILD_FLAGS
|
||||||
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
||||||
|
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
@@ -168,7 +129,7 @@ steps:
|
|||||||
environment:
|
environment:
|
||||||
CC: clang-9
|
CC: clang-9
|
||||||
CXX: clang++-9
|
CXX: clang++-9
|
||||||
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION=haswell;westmere;fallback
|
CMAKE_FLAGS: -DSIMDJSON_SANITIZE=ON -DSIMDJSON_IMPLEMENTATION=icelake;haswell;westmere;fallback
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
@@ -177,6 +138,7 @@ steps:
|
|||||||
- cmake $CMAKE_FLAGS ..
|
- cmake $CMAKE_FLAGS ..
|
||||||
- cmake --build . $BUILD_FLAGS
|
- cmake --build . $BUILD_FLAGS
|
||||||
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L acceptance -LE per_implementation
|
||||||
|
- SIMDJSON_FORCE_IMPLEMENTATION=icelake ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=haswell ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=westmere ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
- SIMDJSON_FORCE_IMPLEMENTATION=fallback ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -L per_implementation
|
||||||
@@ -213,7 +175,7 @@ steps:
|
|||||||
CC: gcc
|
CC: gcc
|
||||||
CXX: g++
|
CXX: g++
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_IMPLEMENTATION=arm64;fallback
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=arm64;fallback
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
||||||
@@ -237,7 +199,7 @@ steps:
|
|||||||
environment:
|
environment:
|
||||||
CC: clang-6.0
|
CC: clang-6.0
|
||||||
CXX: clang++-6.0
|
CXX: clang++-6.0
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
@@ -260,7 +222,7 @@ steps:
|
|||||||
CC: gcc
|
CC: gcc
|
||||||
CXX: g++
|
CXX: g++
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
- echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list
|
||||||
@@ -281,7 +243,7 @@ steps:
|
|||||||
environment:
|
environment:
|
||||||
CC: clang-6.0
|
CC: clang-6.0
|
||||||
CXX: clang++-6.0
|
CXX: clang++-6.0
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=ON
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
commands:
|
commands:
|
||||||
@@ -302,7 +264,7 @@ steps:
|
|||||||
image: gcc:8
|
image: gcc:8
|
||||||
environment:
|
environment:
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_IMPLEMENTATION=arm64;fallback
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_IMPLEMENTATION=arm64;fallback
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
CC: gcc
|
CC: gcc
|
||||||
CXX: g++
|
CXX: g++
|
||||||
@@ -356,7 +318,7 @@ steps:
|
|||||||
CC: clang-9
|
CC: clang-9
|
||||||
CXX: clang++-9
|
CXX: clang++-9
|
||||||
BUILD_FLAGS: -- -j 4
|
BUILD_FLAGS: -- -j 4
|
||||||
CMAKE_FLAGS: -GNinja -DSIMDJSON_BUILD_STATIC=ON
|
CMAKE_FLAGS: -GNinja -DBUILD_SHARED_LIBS=OFF
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
CXXFLAGS: -stdlib=libc++
|
CXXFLAGS: -stdlib=libc++
|
||||||
commands:
|
commands:
|
||||||
@@ -377,7 +339,7 @@ steps:
|
|||||||
CC: clang-9
|
CC: clang-9
|
||||||
CXX: clang++-9
|
CXX: clang++-9
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
CXXFLAGS: -stdlib=libc++
|
CXXFLAGS: -stdlib=libc++
|
||||||
commands:
|
commands:
|
||||||
@@ -398,7 +360,7 @@ steps:
|
|||||||
CC: clang-7
|
CC: clang-7
|
||||||
CXX: clang++-7
|
CXX: clang++-7
|
||||||
BUILD_FLAGS: -- -j
|
BUILD_FLAGS: -- -j
|
||||||
CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=ON
|
CMAKE_FLAGS: -DBUILD_SHARED_LIBS=OFF
|
||||||
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
CTEST_FLAGS: -j4 --output-on-failure -LE explicitonly
|
||||||
CXXFLAGS: -stdlib=libc++
|
CXXFLAGS: -stdlib=libc++
|
||||||
commands:
|
commands:
|
||||||
@@ -444,8 +406,8 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- apt-get -qq update
|
- apt-get -qq update
|
||||||
- apt-get install -q -y clang cmake git wget zip ninja-build
|
- apt-get install -q -y clang cmake git wget zip ninja-build
|
||||||
- wget --quiet https://dl.bintray.com/pauldreik/simdjson-fuzz-corpus/corpus/corpus.tar
|
- wget -O corpus.tar.gz https://readonly:readonly@www.pauldreik.se/fuzzdata/index.php?project=simdjson
|
||||||
- tar xf corpus.tar && rm corpus.tar
|
- tar xf corpus.tar.gz && rm corpus.tar.gz
|
||||||
- fuzz/build_like_ossfuzz.sh
|
- fuzz/build_like_ossfuzz.sh
|
||||||
- mkdir -p common_out
|
- mkdir -p common_out
|
||||||
- for fuzzer in build/fuzz/fuzz_* ; do echo $fuzzer;$fuzzer common_out out/* -max_total_time=40; done
|
- for fuzzer in build/fuzz/fuzz_* ; do echo $fuzzer;$fuzzer common_out out/* -max_total_time=40; done
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
* text=auto
|
* text=auto
|
||||||
|
|
||||||
# we don't want json files to be modified for this project
|
# we don't want json files to be modified for this project
|
||||||
*.json binary
|
*.json binary diff=astextplain
|
||||||
|
|
||||||
|
|
||||||
# Common settings that generally should always be used with your language specific settings
|
# Common settings that generally should always be used with your language specific settings
|
||||||
|
|||||||
@@ -18,19 +18,34 @@ Before submitting an issue, please ensure that you have read the documentation:
|
|||||||
**Describe the bug**
|
**Describe the bug**
|
||||||
A clear and concise description of what the bug is.
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
Note that a compiler warning is not a bug.
|
A compiler or static-analyzer warning is not a bug.
|
||||||
|
|
||||||
|
We are committed to providing good documentation. We accept the lack of documentation or a misleading documentation as a bug (a 'documentation bug').
|
||||||
|
|
||||||
|
We accept the identification of an issue by a sanitizer or some checker tool (e.g., valgrind) as a bug, but you must first ensure that it is not a false positive.
|
||||||
|
|
||||||
|
We recommend that you run your tests using different optimization levels.
|
||||||
|
|
||||||
|
Before reporting a bug, please ensure that you have read our documentation.
|
||||||
|
|
||||||
**To Reproduce**
|
**To Reproduce**
|
||||||
Steps to reproduce the behaviour: provide a code sample if possible.
|
Steps to reproduce the behaviour: provide a code sample if possible.
|
||||||
|
|
||||||
If we cannot reproduce the issue, then we cannot address it.
|
If we cannot reproduce the issue, then we cannot address it. Note that a stack trace from your own program is not enough. A sample of your source code is insufficient: please provide a complete test for us to reproduce the issue. Please reduce the issue: use as small and as simple an example of the bug as possible.
|
||||||
|
|
||||||
Note that a stack trace from your own program is not enough.
|
It should be possible to trigger the bug by using solely simdjson with our default build setup. If you can only observe the bug within some specific context, with some other software, please reduce the issue first.
|
||||||
|
|
||||||
**Configuration (please complete the following information if relevant):**
|
**simjson release**
|
||||||
|
|
||||||
|
Unless you plan to contribute to simdjson, you should only work from releases. Please be mindful that our main branch may have additional features, bugs and documentation items.
|
||||||
|
|
||||||
|
It is fine to report bugs against our main branch, but if that is what you are doing, please be explicit.
|
||||||
|
|
||||||
|
**Configuration (please complete the following information if relevant)**
|
||||||
- OS: [e.g. Ubuntu 16.04.6 LTS]
|
- OS: [e.g. Ubuntu 16.04.6 LTS]
|
||||||
- Compiler [e.g. Apple clang version 11.0.3 (clang-1103.0.32.59) x86_64-apple-darwin19.4.0]
|
- Compiler [e.g. Apple clang version 11.0.3 (clang-1103.0.32.59) x86_64-apple-darwin19.4.0]
|
||||||
- Version [e.g. 22]
|
- Version [e.g. 22]
|
||||||
|
- Optimization setting (e.g., -O3)
|
||||||
|
|
||||||
We support up-to-date 64-bit ARM and x64 FreeBSD, macOS, Windows and Linux systems. Please ensure that your configuration is supported before labelling the issue as a bug. In particular, we do not support legacy 32-bit systems.
|
We support up-to-date 64-bit ARM and x64 FreeBSD, macOS, Windows and Linux systems. Please ensure that your configuration is supported before labelling the issue as a bug. In particular, we do not support legacy 32-bit systems.
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
name: Alpine Linux
|
name: Alpine Linux
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
@@ -15,8 +9,8 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -31,7 +25,7 @@ jobs:
|
|||||||
./alpine.sh apk add build-base cmake g++ linux-headers git bash
|
./alpine.sh apk add build-base cmake g++ linux-headers git bash
|
||||||
- name: cmake
|
- name: cmake
|
||||||
run: |
|
run: |
|
||||||
./alpine.sh cmake -B build_for_alpine
|
./alpine.sh cmake -DSIMDJSON_DEVELOPER_MODE=ON -B build_for_alpine
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
./alpine.sh cmake --build build_for_alpine
|
./alpine.sh cmake --build build_for_alpine
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
name: CIFuzz
|
||||||
|
on: [pull_request]
|
||||||
|
jobs:
|
||||||
|
Fuzzing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Build Fuzzers
|
||||||
|
id: build
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'simdjson'
|
||||||
|
dry-run: false
|
||||||
|
- name: Run Fuzzers
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'simdjson'
|
||||||
|
fuzz-seconds: 600
|
||||||
|
dry-run: false
|
||||||
|
- name: Upload Crash
|
||||||
|
uses: actions/upload-artifact@v1
|
||||||
|
if: failure() && steps.build.outcome == 'success'
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out/artifacts
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
name: Detect trailing whitespace
|
name: Detect trailing whitespace
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
whitespace:
|
whitespace:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Remove whitespace and check the diff
|
- name: Remove whitespace and check the diff
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
|
|||||||
@@ -37,13 +37,25 @@ jobs:
|
|||||||
chmod +x llvm.sh
|
chmod +x llvm.sh
|
||||||
sudo ./llvm.sh $CLANGVERSION
|
sudo ./llvm.sh $CLANGVERSION
|
||||||
|
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
id: cache-corpus
|
||||||
|
with:
|
||||||
|
path: out/
|
||||||
|
key: corpus-${{ github.run_id }}
|
||||||
|
restore-keys: corpus-
|
||||||
|
|
||||||
|
- name: show statistics for the cached corpus
|
||||||
|
run: |
|
||||||
|
echo number of files in github action corpus cache:
|
||||||
|
find out -type f |wc -l
|
||||||
|
|
||||||
- name: Create and prepare the initial seed corpus
|
- name: Create and prepare the initial seed corpus
|
||||||
run: |
|
run: |
|
||||||
fuzz/build_corpus.sh
|
fuzz/build_corpus.sh
|
||||||
@@ -51,12 +63,6 @@ jobs:
|
|||||||
mkdir seedcorpus
|
mkdir seedcorpus
|
||||||
unzip -q -d seedcorpus seed_corpus.zip
|
unzip -q -d seedcorpus seed_corpus.zip
|
||||||
|
|
||||||
- name: Download the corpus from the last run
|
|
||||||
run: |
|
|
||||||
wget --quiet https://dl.bintray.com/pauldreik/simdjson-fuzz-corpus/corpus/corpus.tar
|
|
||||||
tar xf corpus.tar
|
|
||||||
rm corpus.tar
|
|
||||||
|
|
||||||
- name: List clang versions
|
- name: List clang versions
|
||||||
run: |
|
run: |
|
||||||
ls /usr/bin/clang*
|
ls /usr/bin/clang*
|
||||||
@@ -70,7 +76,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -eux
|
set -eux
|
||||||
for fuzzer in $defaultimplfuzzers $implfuzzers; do
|
for fuzzer in $defaultimplfuzzers $implfuzzers; do
|
||||||
mkdir -p out/$fuzzer # in case this is a new fuzzer, or corpus.tar is broken
|
mkdir -p out/$fuzzer # in case this is a new fuzzer, or the github action cached corpus is broken
|
||||||
# get input from everyone else (corpus cross pollination)
|
# get input from everyone else (corpus cross pollination)
|
||||||
others=$(find out -type d -not -name $fuzzer -not -name out -not -name cmin)
|
others=$(find out -type d -not -name $fuzzer -not -name out -not -name cmin)
|
||||||
build-fast/fuzz/fuzz_$fuzzer out/$fuzzer $others seedcorpus -max_total_time=30 $MAXLEN
|
build-fast/fuzz/fuzz_$fuzzer out/$fuzzer $others seedcorpus -max_total_time=30 $MAXLEN
|
||||||
@@ -123,6 +129,11 @@ jobs:
|
|||||||
name: corpus
|
name: corpus
|
||||||
path: corpus.tar
|
path: corpus.tar
|
||||||
|
|
||||||
|
- name: Store the corpus externally
|
||||||
|
run: |
|
||||||
|
gzip --keep corpus.tar
|
||||||
|
curl -F"filedata=@corpus.tar.gz" https://simdjson:${{ secrets.fuzzdatapassword }}@www.pauldreik.se/fuzzdata/index.php
|
||||||
|
|
||||||
# This takes a subset of the minimized corpus and run it through valgrind. It is slow,
|
# This takes a subset of the minimized corpus and run it through valgrind. It is slow,
|
||||||
# therefore take a "random" subset. The random selection is accomplished by sorting on filenames,
|
# therefore take a "random" subset. The random selection is accomplished by sorting on filenames,
|
||||||
# which are hashes of the content.
|
# which are hashes of the content.
|
||||||
@@ -143,15 +154,6 @@ jobs:
|
|||||||
path: valgrind.tar
|
path: valgrind.tar
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|
||||||
- name: Upload the corpus and results to bintray if we are on master
|
|
||||||
if: ${{ github.event_name == 'schedule' }}
|
|
||||||
run: |
|
|
||||||
echo uploading each artifact twice, otherwise it will not be published
|
|
||||||
curl -T corpus.tar -upauldreik:${{ secrets.bintrayApiKey }} https://api.bintray.com/content/pauldreik/simdjson-fuzz-corpus/corpus/0/corpus/corpus.tar";publish=1;override=1"
|
|
||||||
curl -T corpus.tar -upauldreik:${{ secrets.bintrayApiKey }} https://api.bintray.com/content/pauldreik/simdjson-fuzz-corpus/corpus/0/corpus/corpus.tar";publish=1;override=1"
|
|
||||||
curl -T valgrind.tar -upauldreik:${{ secrets.bintrayApiKey }} https://api.bintray.com/content/pauldreik/simdjson-fuzz-corpus/corpus/0/corpus/valgrind.tar";publish=1;override=1"
|
|
||||||
curl -T valgrind.tar -upauldreik:${{ secrets.bintrayApiKey }} https://api.bintray.com/content/pauldreik/simdjson-fuzz-corpus/corpus/0/corpus/valgrind.tar";publish=1;override=1"
|
|
||||||
|
|
||||||
- name: Archive any crashes as an artifact
|
- name: Archive any crashes as an artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
name: Macos (Xcode 11)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
macos-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
xcversion select 11.7
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cmake --install . &&
|
||||||
|
echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json &&
|
||||||
|
cd ../tests/installation_tests/find &&
|
||||||
|
mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build .
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
name: Macos
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
macos-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cmake --install . &&
|
||||||
|
echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json &&
|
||||||
|
cd ../tests/installation_tests/find &&
|
||||||
|
mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build .
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
name: MinGW32-CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
# Important: scoop will either install 32-bit GCC or 64-bit GCC, not both.
|
|
||||||
|
|
||||||
# It is important to build static libraries because cmake is not smart enough under Windows/mingw to take care of the path. So
|
|
||||||
# with a dynamic library, you could get failures due to the fact that the EXE can't find its DLL.
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ci:
|
|
||||||
if: >-
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
|
||||||
name: windows-gcc
|
|
||||||
runs-on: windows-2016
|
|
||||||
|
|
||||||
env:
|
|
||||||
CMAKE_GENERATOR: Ninja # This is critical, try ' cmake -GNinja-DSIMDJSON_BUILD_STATIC=ON .. ' if using the command line
|
|
||||||
CC: gcc
|
|
||||||
CXX: g++
|
|
||||||
|
|
||||||
steps: # To reproduce what is below, start a powershell with administrative rights, using scoop *is* a good idea
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2 # we cache the scoop setup with 32-bit GCC
|
|
||||||
id: cache
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
C:\ProgramData\scoop
|
|
||||||
key: scoop32 # static key: should be good forever
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: dependencies/.cache
|
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
|
||||||
|
|
||||||
- name: Setup Windows # This should almost never run if the cache works.
|
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
|
||||||
scoop install sudo --global
|
|
||||||
sudo scoop install git --global
|
|
||||||
sudo scoop install ninja --global
|
|
||||||
sudo scoop install cmake --global
|
|
||||||
sudo scoop install gcc --arch 32bit --global
|
|
||||||
$env:path
|
|
||||||
Write-Host 'Everything has been installed, you are good!'
|
|
||||||
- name: Build and Test 32-bit x86
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
$ENV:PATH="C:\ProgramData\scoop\shims;C:\ProgramData\scoop\apps\gcc\current\bin;C:\ProgramData\scoop\apps\ninja\current;$ENV:PATH"
|
|
||||||
g++ --version
|
|
||||||
cmake --version
|
|
||||||
ninja --version
|
|
||||||
git --version
|
|
||||||
mkdir build32
|
|
||||||
cd build32
|
|
||||||
cmake -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_ENABLE_THREADS=OFF ..
|
|
||||||
cmake --build . --target acceptance_tests --verbose
|
|
||||||
ctest -L acceptance --output-on-failure
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
name: MinGW64-CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
# Important: scoop will either install 32-bit GCC or 64-bit GCC, not both.
|
|
||||||
|
|
||||||
# It is important to build static libraries because cmake is not smart enough under Windows/mingw to take care of the path. So
|
|
||||||
# with a dynamic library, you could get failures due to the fact that the EXE can't find its DLL.
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ci:
|
|
||||||
if: >-
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
|
||||||
name: windows-gcc
|
|
||||||
runs-on: windows-2016
|
|
||||||
|
|
||||||
env:
|
|
||||||
CMAKE_GENERATOR: Ninja # This is critical, try ' cmake -GNinja-DSIMDJSON_BUILD_STATIC=ON .. ' if using the command line
|
|
||||||
CC: gcc
|
|
||||||
CXX: g++
|
|
||||||
|
|
||||||
steps: # To reproduce what is below, start a powershell with administrative rights, using scoop *is* a good idea
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2 # we cache the scoop setup with 64-bit GCC
|
|
||||||
id: cache
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
C:\ProgramData\scoop
|
|
||||||
key: scoop64 # static key: should be good forever
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: dependencies/.cache
|
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
|
||||||
|
|
||||||
- name: Setup Windows # This should almost never run if the cache works.
|
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
|
||||||
scoop install sudo --global
|
|
||||||
sudo scoop install git --global
|
|
||||||
sudo scoop install ninja --global
|
|
||||||
sudo scoop install cmake --global
|
|
||||||
sudo scoop install gcc --arch 64bit --global
|
|
||||||
$env:path
|
|
||||||
Write-Host 'Everything has been installed, you are good!'
|
|
||||||
- name: Build and Test 64-bit x64
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
$ENV:PATH="C:\ProgramData\scoop\shims;C:\ProgramData\scoop\apps\gcc\current\bin;C:\ProgramData\scoop\apps\ninja\current;$ENV:PATH"
|
|
||||||
g++ --version
|
|
||||||
cmake --version
|
|
||||||
ninja --version
|
|
||||||
git --version
|
|
||||||
mkdir build64
|
|
||||||
cd build64
|
|
||||||
cmake -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_ENABLE_THREADS=OFF ..
|
|
||||||
cmake --build . --target acceptance_tests --verbose
|
|
||||||
ctest -L acceptance --output-on-failure
|
|
||||||
cd ..
|
|
||||||
mkdir build64debug
|
|
||||||
cd build64debug
|
|
||||||
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_ENABLE_THREADS=OFF ..
|
|
||||||
cmake --build . --target acceptance_tests --verbose
|
|
||||||
ctest -L acceptance --output-on-failure
|
|
||||||
@@ -1,12 +1,7 @@
|
|||||||
name: MSYS2-CLANG-CI
|
name: MSYS2-CLANG-CI
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
windows-mingw:
|
windows-mingw:
|
||||||
@@ -20,23 +15,17 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- msystem: "MINGW64"
|
- msystem: "MINGW64"
|
||||||
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
install: mingw-w64-x86_64-libxml2 mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
||||||
type: Release
|
|
||||||
- msystem: "MINGW32"
|
|
||||||
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-clang
|
|
||||||
type: Release
|
type: Release
|
||||||
- msystem: "MINGW64"
|
- msystem: "MINGW64"
|
||||||
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
install: mingw-w64-x86_64-libxml2 mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-clang
|
||||||
type: Debug
|
|
||||||
- msystem: "MINGW32"
|
|
||||||
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-clang
|
|
||||||
type: Debug
|
type: Debug
|
||||||
env:
|
env:
|
||||||
CMAKE_GENERATOR: Ninja
|
CMAKE_GENERATOR: Ninja
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -49,6 +38,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT=ON ..
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT=ON ..
|
||||||
cmake --build . --verbose
|
cmake --build . --verbose
|
||||||
ctest -j4 --output-on-failure -LE explicitonly
|
ctest -j4 --output-on-failure -LE explicitonly
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
name: MSYS2-CI
|
name: MSYS2-CI
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
windows-mingw:
|
windows-mingw:
|
||||||
@@ -25,21 +19,15 @@ jobs:
|
|||||||
- msystem: "MINGW64"
|
- msystem: "MINGW64"
|
||||||
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
||||||
type: Release
|
type: Release
|
||||||
- msystem: "MINGW32"
|
|
||||||
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
|
|
||||||
type: Release
|
|
||||||
- msystem: "MINGW64"
|
- msystem: "MINGW64"
|
||||||
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
install: mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-gcc
|
||||||
type: Debug
|
type: Debug
|
||||||
- msystem: "MINGW32"
|
|
||||||
install: mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-gcc
|
|
||||||
type: Debug
|
|
||||||
env:
|
env:
|
||||||
CMAKE_GENERATOR: Ninja
|
CMAKE_GENERATOR: Ninja
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -52,6 +40,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DSIMDJSON_BUILD_STATIC=ON -DSIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT=ON ..
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DBUILD_SHARED_LIBS=OFF -DSIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT=ON ..
|
||||||
cmake --build . --verbose
|
cmake --build . --verbose
|
||||||
ctest -j4 --output-on-failure -LE explicitonly
|
ctest -j4 --output-on-failure -LE explicitonly
|
||||||
|
|||||||
@@ -32,13 +32,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
export CLANGSUFFIX="-7"
|
export CLANGSUFFIX="-7"
|
||||||
apt-get -qq update
|
apt-get -qq update
|
||||||
apt-get install -q -y clang-7 libfuzzer-7-dev cmake git wget zip ninja-build
|
apt-get install -q -y clang-7 libfuzzer-7-dev git wget zip ninja-build gnupg software-properties-common
|
||||||
|
wget -q -O - "https://raw.githubusercontent.com/simdjson/debian-ppa/master/key.gpg" | apt-key add -
|
||||||
|
apt-add-repository "deb https://raw.githubusercontent.com/simdjson/debian-ppa/master simdjson main"
|
||||||
|
apt-get -qq update
|
||||||
|
apt-get purge cmake cmake-data
|
||||||
|
apt-get -t simdjson -y install cmake
|
||||||
mkdir -p build ; cd build
|
mkdir -p build ; cd build
|
||||||
cmake .. -GNinja \
|
cmake .. -GNinja \
|
||||||
-DCMAKE_CXX_COMPILER=clang++$CLANGSUFFIX \
|
-DCMAKE_CXX_COMPILER=clang++$CLANGSUFFIX \
|
||||||
-DCMAKE_C_COMPILER=clang$CLANGSUFFIX \
|
-DCMAKE_C_COMPILER=clang$CLANGSUFFIX \
|
||||||
-DSIMDJSON_BUILD_STATIC=Off \
|
-DBUILD_SHARED_LIBS=OFF \
|
||||||
-DENABLE_FUZZING=On \
|
-DSIMDJSON_DEVELOPER_MODE=ON \
|
||||||
|
-DSIMDJSON_ENABLE_FUZZING=On \
|
||||||
-DSIMDJSON_COMPETITION=OFF \
|
-DSIMDJSON_COMPETITION=OFF \
|
||||||
-DSIMDJSON_GOOGLE_BENCHMARKS=OFF \
|
-DSIMDJSON_GOOGLE_BENCHMARKS=OFF \
|
||||||
-DSIMDJSON_DISABLE_DEPRECATED_API=On \
|
-DSIMDJSON_DISABLE_DEPRECATED_API=On \
|
||||||
@@ -50,8 +56,8 @@ jobs:
|
|||||||
cd ..
|
cd ..
|
||||||
builddir=build
|
builddir=build
|
||||||
cmake --build $builddir
|
cmake --build $builddir
|
||||||
wget --quiet https://dl.bintray.com/pauldreik/simdjson-fuzz-corpus/corpus/corpus.tar
|
wget -O corpus.tar.gz https://readonly:readonly@www.pauldreik.se/fuzzdata/index.php?project=simdjson
|
||||||
tar xf corpus.tar && rm corpus.tar
|
tar xf corpus.tar.gz
|
||||||
fuzzernames=$(cmake --build $builddir --target print_all_fuzzernames |tail -n1)
|
fuzzernames=$(cmake --build $builddir --target print_all_fuzzernames |tail -n1)
|
||||||
for fuzzer in $fuzzernames ; do
|
for fuzzer in $fuzzernames ; do
|
||||||
exe=$builddir/fuzz/$fuzzer
|
exe=$builddir/fuzz/$fuzzer
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -24,6 +24,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_ENABLE_DOM_CHECKPERF=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
cmake --build . --target checkperf &&
|
cmake --build . --target checkperf &&
|
||||||
ctest --output-on-failure -R checkperf ubuntu18-checkperf.yml
|
ctest --output-on-failure -R checkperf ubuntu18-checkperf.yml
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
name: Ubuntu 18.04 CI (LLVM 7)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
|
||||||
|
env:
|
||||||
|
CC: clang-7
|
||||||
|
CXX: clang++-7
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: install clang 7
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install clang-7
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly
|
||||||
@@ -1,12 +1,7 @@
|
|||||||
name: Ubuntu 18.04 CI (GCC 7) with Thread Sanitizer
|
name: Ubuntu 18.04 CI (GCC 7) with Thread Sanitizer
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
@@ -15,8 +10,8 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -24,7 +19,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DSIMDJSON_SANITIZE_THREADS=ON .. &&
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_SANITIZE_THREADS=ON .. &&
|
||||||
cmake --build . --target document_stream_tests --target parse_many_test &&
|
cmake --build . --target document_stream_tests --target ondemand_document_stream_tests --target parse_many_test &&
|
||||||
ctest --output-on-failure -R parse_many_test &&
|
ctest --output-on-failure -R parse_many_test &&
|
||||||
ctest --output-on-failure -R document_stream_tests
|
ctest --output-on-failure -R document_stream_tests
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
name: Ubuntu 18.04 CI (GCC 7)
|
name: Ubuntu 18.04 CI (GCC 7)
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
@@ -15,8 +9,8 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -24,7 +18,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
cmake --build . &&
|
cmake --build . &&
|
||||||
ctest -j --output-on-failure -LE explicitonly &&
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
make install &&
|
make install &&
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -24,6 +24,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DCMAKE_CXX_FLAGS="-Werror=old-style-cast -pedantic -Wpedantic" -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_ENABLE_DOM_CHECKPERF=ON -DCMAKE_CXX_FLAGS="-Werror=old-style-cast -pedantic -Wpedantic" -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
cmake --build . --target checkperf &&
|
cmake --build . --target checkperf &&
|
||||||
ctest --output-on-failure -R checkperf
|
ctest --output-on-failure -R checkperf
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
name: Ubuntu 20.04 CI (GCC 8)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
env:
|
||||||
|
CXX: g++-8
|
||||||
|
CC: gcc-8
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Install GCC 8
|
||||||
|
run: sudo apt-get install -y g++-8
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cmake --install . &&
|
||||||
|
echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json &&
|
||||||
|
cd ../tests/installation_tests/find &&
|
||||||
|
mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build .
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
name: Ubuntu 20.04 CI (GCC 9) without exceptions
|
name: Ubuntu 20.04 CI (GCC 9) without exceptions
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
@@ -15,16 +9,22 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
- name: Use cmake
|
- name: Use cmake
|
||||||
run: |
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_EXCEPTIONS=OFF -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_EXCEPTIONS=OFF -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_EXCEPTIONS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
cmake --build . &&
|
cmake --build . &&
|
||||||
ctest -j --output-on-failure -LE explicitonly &&
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
make install &&
|
make install &&
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
name: Ubuntu 20.04 CI (GCC 9) without threads
|
name: Ubuntu 20.04 CI (GCC 9) Without Threads
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
@@ -15,16 +9,22 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
- name: Use cmake
|
- name: Use cmake
|
||||||
run: |
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_ENABLE_THREADS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_ENABLE_THREADS=OFF -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_ENABLE_THREADS=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
cmake --build . &&
|
cmake --build . &&
|
||||||
ctest -j --output-on-failure -LE explicitonly &&
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
make install &&
|
make install &&
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name: Ubuntu 20.04 CI (GCC 9) With Memory Sanitizer
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DSIMDJSON_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
name: Ubuntu 20.04 CI (GCC 9) with Thread Sanitizer
|
name: Ubuntu 20.04 CI (GCC 9) with Thread Sanitizer
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
@@ -15,8 +9,8 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
@@ -24,7 +18,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DSIMDJSON_SANITIZE_THREADS=ON .. &&
|
cmake -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_SANITIZE_THREADS=ON .. &&
|
||||||
cmake --build . --target document_stream_tests --target parse_many_test &&
|
cmake --build . --target document_stream_tests --target ondemand_document_stream_tests --target parse_many_test &&
|
||||||
ctest --output-on-failure -R parse_many_test &&
|
ctest --output-on-failure -R parse_many_test &&
|
||||||
ctest --output-on-failure -R document_stream_tests
|
ctest --output-on-failure -R document_stream_tests
|
||||||
@@ -1,12 +1,6 @@
|
|||||||
name: Ubuntu 20.04 CI (GCC 9)
|
name: Ubuntu 20.04 CI (GCC 9)
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu-build:
|
ubuntu-build:
|
||||||
@@ -15,16 +9,22 @@ jobs:
|
|||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
- name: Use cmake
|
- name: Use cmake
|
||||||
run: |
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
mkdir build &&
|
mkdir build &&
|
||||||
cd build &&
|
cd build &&
|
||||||
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
cmake --build . &&
|
cmake --build . &&
|
||||||
ctest -j --output-on-failure -LE explicitonly &&
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
cmake --install . &&
|
cmake --install . &&
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
name: Ubuntu 22.04 CI (CLANG 13)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Install clang++-13
|
||||||
|
run: sudo apt-get install -y clang++-13
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
CXX=clang++-13 cmake -DSIMDJSON_DEVELOPER_MODE=ON .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
name: Ubuntu 22.04 CI (GCC 12)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Install gcc12
|
||||||
|
run: sudo apt-get install -y g++-12
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
CXX=g++-12 cmake -DSIMDJSON_DEVELOPER_MODE=ON .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
name: Ubuntu 22.04 CI (GCC 11)
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
if: >-
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir builddebug &&
|
||||||
|
cd builddebug &&
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cd .. &&
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX:PATH=destination .. &&
|
||||||
|
cmake --build . &&
|
||||||
|
ctest -j --output-on-failure -LE explicitonly &&
|
||||||
|
cmake --install . &&
|
||||||
|
echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json &&
|
||||||
|
cd ../tests/installation_tests/find &&
|
||||||
|
mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build .
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
name: VS16-CLANG-CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ci:
|
|
||||||
if: >-
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
|
||||||
name: windows-vs16
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: dependencies/.cache
|
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
|
||||||
- name: 'Run CMake with VS16 Clang'
|
|
||||||
uses: lukka/run-cmake@v3
|
|
||||||
with:
|
|
||||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
|
||||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
|
||||||
buildDirectory: "${{ github.workspace }}/../../_temp/windows"
|
|
||||||
cmakeBuildType: Release
|
|
||||||
buildWithCMake: true
|
|
||||||
cmakeAppendedArgs: -T ClangCL -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_BUILD_STATIC=ON
|
|
||||||
buildWithCMakeArgs: --config Release
|
|
||||||
|
|
||||||
- name: 'Run CTest'
|
|
||||||
run: ctest -C Release -LE explicitonly --output-on-failure
|
|
||||||
working-directory: "${{ github.workspace }}/../../_temp/windows"
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
name: VS16-Ninja-CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ci:
|
|
||||||
if: >-
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
|
||||||
name: windows-vs16
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: dependencies/.cache
|
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
|
||||||
- name: 'Run CMake with VS16'
|
|
||||||
uses: lukka/run-cmake@v2
|
|
||||||
with:
|
|
||||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
|
||||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
|
||||||
buildDirectory: "${{ github.workspace }}/../../_temp/windows"
|
|
||||||
cmakeBuildType: Release
|
|
||||||
buildWithCMake: true
|
|
||||||
cmakeAppendedArgs: -G Ninja -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_BUILD_STATIC=ON
|
|
||||||
buildWithCMakeArgs: --config Release
|
|
||||||
- name: 'Run CTest'
|
|
||||||
run: ctest -C Release -LE explicitonly --output-on-failure
|
|
||||||
working-directory: "${{ github.workspace }}/../../_temp/windows"
|
|
||||||
- name: 'Install with CMake'
|
|
||||||
uses: lukka/run-cmake@v3
|
|
||||||
with:
|
|
||||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
|
||||||
buildWithCMakeArgs: '--target install'
|
|
||||||
- name: 'Test Installation with CMake'
|
|
||||||
uses: lukka/run-cmake@v3
|
|
||||||
with:
|
|
||||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
|
||||||
cmakeListsTxtPath: '${{ github.workspace }}/tests/installation_tests/find/CMakeLists.txt'
|
|
||||||
cmakeBuildType: Release
|
|
||||||
buildWithCMake: true
|
|
||||||
buildDirectory: '${{ github.workspace }}/tests/installation_tests/find/buildDirectory'
|
|
||||||
cmakeAppendedArgs: -G Ninja
|
|
||||||
buildWithCMakeArgs: '--config Release --verbose'
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
name: VS17-ARM-CI
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
name: windows-vs17
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- {arch: ARM}
|
||||||
|
- {arch: ARM64}
|
||||||
|
steps:
|
||||||
|
- name: checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
cmake -A ${{ matrix.arch }} -DCMAKE_CROSSCOMPILING=1 -DSIMDJSON_DEVELOPER_MODE=ON -D SIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_EXCEPTIONS=OFF -B build &&
|
||||||
|
cmake --build build --verbose
|
||||||
@@ -1,42 +1,40 @@
|
|||||||
name: VS16-CI
|
name: VS17-CI
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
if: >-
|
if: >-
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
name: windows-vs16
|
name: windows-vs17
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- {gen: Visual Studio 16 2019, arch: Win32, static: ON}
|
- {gen: Visual Studio 17 2022, arch: Win32, shared: ON}
|
||||||
- {gen: Visual Studio 16 2019, arch: Win32, static: OFF}
|
- {gen: Visual Studio 17 2022, arch: Win32, shared: OFF}
|
||||||
- {gen: Visual Studio 16 2019, arch: x64, static: ON}
|
- {gen: Visual Studio 17 2022, arch: x64, shared: ON}
|
||||||
- {gen: Visual Studio 16 2019, arch: x64, static: OFF}
|
- {gen: Visual Studio 17 2022, arch: x64, shared: OFF}
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: |
|
run: |
|
||||||
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_BUILD_STATIC=${{matrix.static}} -B build
|
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_COMPETITION=OFF -DBUILD_SHARED_LIBS=${{matrix.shared}} -B build
|
||||||
- name: Build Debug
|
- name: Build Debug
|
||||||
run: cmake --build build --config Debug --verbose
|
run: cmake --build build --config Debug --verbose
|
||||||
- name: Build Release
|
- name: Build Release
|
||||||
run: cmake --build build --config Release --verbose
|
run: cmake --build build --config Release --verbose
|
||||||
- name: Run tests
|
- name: Run Release tests
|
||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
ctest -C Release -LE explicitonly --output-on-failure
|
ctest -C Release -LE explicitonly --output-on-failure
|
||||||
|
- name: Run Debug tests
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
ctest -C Debug -LE explicitonly --output-on-failure
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
cmake --install build --config Release
|
cmake --install build --config Release
|
||||||
@@ -1,42 +1,37 @@
|
|||||||
name: VS15-CI
|
name: VS17-CLANG-CI
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
if: >-
|
if: >-
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
|
||||||
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
! contains(toJSON(github.event.commits.*.message), '[skip github]')
|
||||||
name: windows-vs15
|
name: windows-vs17
|
||||||
runs-on: windows-2016
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- {gen: Visual Studio 15 2017, arch: Win32, static: ON}
|
- {gen: Visual Studio 17 2022, arch: x64}
|
||||||
- {gen: Visual Studio 15 2017, arch: Win32, static: OFF}
|
|
||||||
- {gen: Visual Studio 15 2017, arch: x64, static: ON}
|
|
||||||
- {gen: Visual Studio 15 2017, arch: x64, static: OFF}
|
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: |
|
run: |
|
||||||
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_BUILD_STATIC=${{matrix.static}} -B build
|
cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -T ClangCL -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_COMPETITION=OFF -B build
|
||||||
- name: Build Debug
|
- name: Build Debug
|
||||||
run: cmake --build build --config Debug --verbose
|
run: cmake --build build --config Debug --verbose
|
||||||
- name: Build Release
|
- name: Build Release
|
||||||
run: cmake --build build --config Release --verbose
|
run: cmake --build build --config Release --verbose
|
||||||
- name: Run tests
|
- name: Run Release tests
|
||||||
run: |
|
run: |
|
||||||
cd build
|
cd build
|
||||||
ctest -C Release -LE explicitonly --output-on-failure
|
ctest -C Release -LE explicitonly --output-on-failure
|
||||||
|
- name: Run Debug tests
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
ctest -C Debug -LE explicitonly --output-on-failure
|
||||||
- name: Install
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
cmake --install build --config Release
|
cmake --install build --config Release
|
||||||
@@ -1,24 +1,18 @@
|
|||||||
name: VS16-NoExcept-CI
|
name: VS17-NoExcept-CI
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
name: windows-vs16
|
name: windows-vs17
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: dependencies/.cache
|
path: dependencies/.cache
|
||||||
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
- name: 'Run CMake with VS16'
|
- name: 'Run CMake with VS17'
|
||||||
uses: lukka/run-cmake@v3
|
uses: lukka/run-cmake@v3
|
||||||
with:
|
with:
|
||||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||||
@@ -27,7 +21,7 @@ jobs:
|
|||||||
cmakeBuildType: Release
|
cmakeBuildType: Release
|
||||||
buildWithCMake: true
|
buildWithCMake: true
|
||||||
cmakeGenerator: VS16Win64
|
cmakeGenerator: VS16Win64
|
||||||
cmakeAppendedArgs: -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_EXCEPTIONS=OFF
|
cmakeAppendedArgs: -DSIMDJSON_COMPETITION=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DSIMDJSON_EXCEPTIONS=OFF
|
||||||
buildWithCMakeArgs: --config Release
|
buildWithCMakeArgs: --config Release
|
||||||
|
|
||||||
- name: 'Run CTest'
|
- name: 'Run CTest'
|
||||||
@@ -97,3 +97,10 @@ objs
|
|||||||
# Generated docs
|
# Generated docs
|
||||||
/doc/api
|
/doc/api
|
||||||
*.orig
|
*.orig
|
||||||
|
|
||||||
|
# VSCode workspace files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|||||||
+27
-25
@@ -48,17 +48,18 @@ matrix:
|
|||||||
- COMPILER="CC=gcc-10 && CXX=g++-10"
|
- COMPILER="CC=gcc-10 && CXX=g++-10"
|
||||||
compiler: gcc-10
|
compiler: gcc-10
|
||||||
|
|
||||||
- os: linux
|
# The sanitizer runs fail systematically
|
||||||
addons:
|
# - os: linux
|
||||||
apt:
|
# addons:
|
||||||
sources:
|
# apt:
|
||||||
- ubuntu-toolchain-r-test
|
# sources:
|
||||||
packages:
|
# - ubuntu-toolchain-r-test
|
||||||
- g++-10
|
# packages:
|
||||||
env:
|
# - g++-10
|
||||||
- COMPILER="CC=gcc-10 && CXX=g++-10"
|
# env:
|
||||||
- SANITIZE="on"
|
# - COMPILER="CC=gcc-10 && CXX=g++-10"
|
||||||
compiler: gcc-10-sanitize
|
# - SANITIZE="on"
|
||||||
|
# compiler: gcc-10-sanitize
|
||||||
|
|
||||||
- os: linux
|
- os: linux
|
||||||
addons:
|
addons:
|
||||||
@@ -143,19 +144,20 @@ matrix:
|
|||||||
- STATIC="on"
|
- STATIC="on"
|
||||||
compiler: clang-10-static
|
compiler: clang-10-static
|
||||||
|
|
||||||
- os: linux
|
# The clang sanitizer runs fail frequently at setup time
|
||||||
addons:
|
# - os: linux
|
||||||
apt:
|
# addons:
|
||||||
packages:
|
# apt:
|
||||||
- clang-10
|
# packages:
|
||||||
sources:
|
# - clang-10
|
||||||
- ubuntu-toolchain-r-test
|
# sources:
|
||||||
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
# - ubuntu-toolchain-r-test
|
||||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
# - sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
||||||
env:
|
# key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||||
- COMPILER="CC=clang-10 && CXX=clang++-10"
|
# env:
|
||||||
- SANITIZE="on"
|
# - COMPILER="CC=clang-10 && CXX=clang++-10"
|
||||||
compiler: clang-10-sanitize
|
# - SANITIZE="on"
|
||||||
|
# compiler: clang-10-sanitize
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- eval "${COMPILER}"
|
- eval "${COMPILER}"
|
||||||
@@ -174,7 +176,7 @@ install:
|
|||||||
export ASAN_OPTIONS="detect_leaks=0";
|
export ASAN_OPTIONS="detect_leaks=0";
|
||||||
fi
|
fi
|
||||||
- if [[ "${STATIC}" == "on" ]]; then
|
- if [[ "${STATIC}" == "on" ]]; then
|
||||||
export CMAKE_FLAGS="${CMAKE_FLAGS} -DSIMDJSON_BUILD_STATIC=ON";
|
export CMAKE_FLAGS="${CMAKE_FLAGS} -DBUILD_SHARED_LIBS=OFF";
|
||||||
fi
|
fi
|
||||||
- export CTEST_FLAGS="-j4 --output-on-failure -LE explicitonly"
|
- export CTEST_FLAGS="-j4 --output-on-failure -LE explicitonly"
|
||||||
|
|
||||||
|
|||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
||||||
|
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||||
|
|
||||||
|
// List of extensions which should be recommended for users of this workspace.
|
||||||
|
"recommendations": [
|
||||||
|
// Syntax
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"ms-vscode.cmake-tools",
|
||||||
|
"ms-python.python",
|
||||||
|
"twxs.cmake"
|
||||||
|
],
|
||||||
|
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||||
|
"unwantedRecommendations": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+91
@@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"editor.rulers": [
|
||||||
|
{"column": 95 },
|
||||||
|
{"column": 120 }
|
||||||
|
],
|
||||||
|
"files.trimTrailingWhitespace": true,
|
||||||
|
"files.associations": {
|
||||||
|
"array": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"chrono": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"__locale": "cpp",
|
||||||
|
"__tuple": "cpp",
|
||||||
|
"__bit_reference": "cpp",
|
||||||
|
"__config": "cpp",
|
||||||
|
"__debug": "cpp",
|
||||||
|
"__errc": "cpp",
|
||||||
|
"__functional_base": "cpp",
|
||||||
|
"__hash_table": "cpp",
|
||||||
|
"__mutex_base": "cpp",
|
||||||
|
"__node_handle": "cpp",
|
||||||
|
"__nullptr": "cpp",
|
||||||
|
"__split_buffer": "cpp",
|
||||||
|
"__string": "cpp",
|
||||||
|
"__threading_support": "cpp",
|
||||||
|
"__tree": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"bitset": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"codecvt": "cpp",
|
||||||
|
"complex": "cpp",
|
||||||
|
"condition_variable": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"forward_list": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"ios": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"locale": "cpp",
|
||||||
|
"map": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"ratio": "cpp",
|
||||||
|
"regex": "cpp",
|
||||||
|
"set": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stack": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"typeinfo": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"unordered_set": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"valarray": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"*.ipp": "cpp",
|
||||||
|
"__functional_base_03": "cpp",
|
||||||
|
"filesystem": "cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
+260
-82
@@ -1,74 +1,222 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
# CMP0025: Compiler id for Apple Clang is now AppleClang.
|
|
||||||
# https://cmake.org/cmake/help/v3.17/policy/CMP0025.html
|
project(
|
||||||
cmake_policy(SET CMP0025 NEW)
|
simdjson
|
||||||
project(simdjson
|
# The version number is modified by tools/release.py
|
||||||
DESCRIPTION "Parsing gigabytes of JSON per second"
|
VERSION 2.0.4
|
||||||
LANGUAGES CXX C
|
DESCRIPTION "Parsing gigabytes of JSON per second"
|
||||||
|
HOMEPAGE_URL "https://simdjson.org/"
|
||||||
|
LANGUAGES CXX C
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PROJECT_VERSION_MAJOR 0)
|
set(SIMDJSON_GITHUB_REPOSITORY "https://github.com/simdjson/simdjson")
|
||||||
set(PROJECT_VERSION_MINOR 9)
|
|
||||||
set(PROJECT_VERSION_PATCH 4)
|
|
||||||
set(SIMDJSON_SEMANTIC_VERSION "0.9.4" CACHE STRING "simdjson semantic version")
|
|
||||||
set(SIMDJSON_LIB_VERSION "8.0.0" CACHE STRING "simdjson library version")
|
|
||||||
set(SIMDJSON_LIB_SOVERSION "8" CACHE STRING "simdjson library soversion")
|
|
||||||
set(SIMDJSON_GITHUB_REPOSITORY https://github.com/simdjson/simdjson)
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
string(
|
||||||
include(cmake/simdjson-flags.cmake)
|
COMPARE EQUAL
|
||||||
include(cmake/simdjson-user-cmakecache.cmake)
|
"${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
is_top_project
|
||||||
|
)
|
||||||
|
|
||||||
|
# ---- Options, variables ----
|
||||||
|
|
||||||
|
# These version numbers are modified by tools/release.py
|
||||||
if(SIMDJSON_JUST_LIBRARY)
|
set(SIMDJSON_LIB_VERSION "11.0.0" CACHE STRING "simdjson library version")
|
||||||
message( STATUS "Building just the library, omitting all tests, tools and benchmarks." )
|
set(SIMDJSON_LIB_SOVERSION "11" CACHE STRING "simdjson library soversion")
|
||||||
else(SIMDJSON_JUST_LIBRARY)
|
|
||||||
# Setup tests
|
|
||||||
enable_testing()
|
|
||||||
add_subdirectory(jsonchecker)
|
|
||||||
add_subdirectory(jsonexamples)
|
|
||||||
add_library(test-data INTERFACE)
|
|
||||||
target_link_libraries(test-data INTERFACE jsonchecker-data jsonchecker-minefield-data jsonexamples-data)
|
|
||||||
endif(SIMDJSON_JUST_LIBRARY)
|
|
||||||
|
|
||||||
# Create the top level simdjson library (must be done at this level to use both src/ and include/
|
|
||||||
# directories) and tools
|
|
||||||
#
|
|
||||||
add_subdirectory(include)
|
|
||||||
add_subdirectory(src)
|
|
||||||
add_subdirectory(windows)
|
|
||||||
if(NOT(SIMDJSON_JUST_LIBRARY))
|
|
||||||
add_subdirectory(dependencies) ## This needs to be before tools because of cxxopts
|
|
||||||
add_subdirectory(tools) ## This needs to be before tests because of cxxopts
|
|
||||||
add_subdirectory(singleheader)
|
|
||||||
endif()
|
|
||||||
install(FILES singleheader/simdjson.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
||||||
|
|
||||||
option(SIMDJSON_ENABLE_THREADS "Link with thread support" ON)
|
option(SIMDJSON_ENABLE_THREADS "Link with thread support" ON)
|
||||||
|
|
||||||
|
include(cmake/simdjson-props.cmake)
|
||||||
|
include(cmake/implementation-flags.cmake)
|
||||||
|
include(cmake/exception-flags.cmake)
|
||||||
|
|
||||||
|
option(SIMDJSON_DISABLE_DEPRECATED_API "Disables deprecated APIs" OFF)
|
||||||
|
if(SIMDJSON_DISABLE_DEPRECATED_API)
|
||||||
|
simdjson_add_props(
|
||||||
|
target_compile_definitions PUBLIC
|
||||||
|
SIMDJSON_DISABLE_DEPRECATED_API=1
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(SIMDJSON_DEVELOPMENT_CHECKS "Enable development-time aids, such as \
|
||||||
|
checks for incorrect API usage. Enabled by default in DEBUG." OFF)
|
||||||
|
if(SIMDJSON_DEVELOPMENT_CHECKS)
|
||||||
|
simdjson_add_props(
|
||||||
|
target_compile_definitions PUBLIC
|
||||||
|
SIMDJSON_DEVELOPMENT_CHECKS
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(is_top_project)
|
||||||
|
option(SIMDJSON_DEVELOPER_MODE "Enable targets for developing simdjson" OFF)
|
||||||
|
option(BUILD_SHARED_LIBS "Build simdjson as a shared library" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(cmake/handle-deprecations.cmake)
|
||||||
|
include(cmake/developer-options.cmake)
|
||||||
|
|
||||||
|
# ---- simdjson library ----
|
||||||
|
|
||||||
|
add_library(simdjson src/simdjson.cpp)
|
||||||
|
add_library(simdjson::simdjson ALIAS simdjson)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
simdjson PROPERTIES
|
||||||
|
VERSION "${SIMDJSON_LIB_VERSION}"
|
||||||
|
SOVERSION "${SIMDJSON_LIB_SOVERSION}"
|
||||||
|
# FIXME: symbols should be hidden by default
|
||||||
|
WINDOWS_EXPORT_ALL_SYMBOLS YES
|
||||||
|
)
|
||||||
|
|
||||||
|
# FIXME: Use proper CMake integration for exports
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(
|
||||||
|
simdjson
|
||||||
|
PRIVATE SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY=1
|
||||||
|
INTERFACE SIMDJSON_USING_WINDOWS_DYNAMIC_LIBRARY=1
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
simdjson_add_props(
|
||||||
|
target_include_directories
|
||||||
|
PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
|
||||||
|
PRIVATE "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>"
|
||||||
|
)
|
||||||
|
|
||||||
|
simdjson_add_props(target_compile_features PUBLIC cxx_std_11)
|
||||||
|
|
||||||
|
# workaround for GNU GCC poor AVX load/store code generation
|
||||||
|
if(
|
||||||
|
CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
||||||
|
AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86(_64)?)$"
|
||||||
|
)
|
||||||
|
simdjson_add_props(
|
||||||
|
target_compile_options PRIVATE
|
||||||
|
-mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIMDJSON_ENABLE_THREADS)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
simdjson_add_props(target_link_libraries PUBLIC Threads::Threads)
|
||||||
|
simdjson_add_props(target_compile_definitions PUBLIC SIMDJSON_THREADS_ENABLED=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
simdjson_apply_props(simdjson)
|
||||||
|
|
||||||
|
# ---- Install rules ----
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
configure_package_config_file("${PROJECT_SOURCE_DIR}/cmake/simdjson-config.cmake.in"
|
include(GNUInstallDirs)
|
||||||
"${PROJECT_BINARY_DIR}/simdjson-config.cmake"
|
|
||||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/simdjson"
|
install(
|
||||||
NO_SET_AND_CHECK_MACRO
|
FILES singleheader/simdjson.h
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
|
COMPONENT simdjson_Development
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS simdjson
|
||||||
|
EXPORT simdjsonTargets
|
||||||
|
RUNTIME COMPONENT simdjson_Runtime
|
||||||
|
LIBRARY COMPONENT simdjson_Runtime
|
||||||
|
NAMELINK_COMPONENT simdjson_Development
|
||||||
|
ARCHIVE COMPONENT simdjson_Development
|
||||||
|
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(cmake/simdjson-config.cmake.in simdjson-config.cmake @ONLY)
|
||||||
|
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
"${PROJECT_BINARY_DIR}/simdjson-config-version.cmake"
|
simdjson-config-version.cmake
|
||||||
VERSION ${SIMDJSON_SEMANTIC_VERSION}
|
COMPATIBILITY SameMinorVersion
|
||||||
COMPATIBILITY SameMinorVersion)
|
)
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/simdjson-config.cmake"
|
|
||||||
"${PROJECT_BINARY_DIR}/simdjson-config-version.cmake"
|
set(
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/simdjson")
|
SIMDJSON_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/simdjson"
|
||||||
|
CACHE STRING "CMake package config location relative to the install prefix"
|
||||||
|
)
|
||||||
|
mark_as_advanced(SIMDJSON_INSTALL_CMAKEDIR)
|
||||||
|
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${PROJECT_BINARY_DIR}/simdjson-config.cmake"
|
||||||
|
"${PROJECT_BINARY_DIR}/simdjson-config-version.cmake"
|
||||||
|
DESTINATION "${SIMDJSON_INSTALL_CMAKEDIR}"
|
||||||
|
COMPONENT simdjson_Development
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
EXPORT simdjsonTargets
|
||||||
|
NAMESPACE simdjson::
|
||||||
|
DESTINATION "${SIMDJSON_INSTALL_CMAKEDIR}"
|
||||||
|
COMPONENT example_Development
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# CPack
|
||||||
|
#
|
||||||
|
if(is_top_project)
|
||||||
|
set(CPACK_PACKAGE_VENDOR "Daniel Lemire")
|
||||||
|
set(CPACK_PACKAGE_CONTACT "lemire@gmail.com")
|
||||||
|
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||||
|
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
|
||||||
|
|
||||||
|
set(CPACK_RPM_PACKAGE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||||
|
|
||||||
|
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ---- Developer mode extras ----
|
||||||
|
|
||||||
|
if(NOT SIMDJSON_DEVELOPER_MODE)
|
||||||
|
message(STATUS "Building only the library. Advanced users may want to turn SIMDJSON_DEVELOPER_MODE to ON, e.g., via -D SIMDJSON_DEVELOPER_MODE=ON.")
|
||||||
|
return()
|
||||||
|
elseif(NOT is_top_project)
|
||||||
|
message(AUTHOR_WARNING "Developer mode is intended for developers of simdjson")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
simdjson_apply_props(simdjson-internal-flags)
|
||||||
|
|
||||||
|
set(
|
||||||
|
SIMDJSON_USER_CMAKECACHE
|
||||||
|
"${CMAKE_BINARY_DIR}/.simdjson-user-CMakeCache.txt"
|
||||||
|
)
|
||||||
|
add_custom_target(
|
||||||
|
simdjson-user-cmakecache
|
||||||
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
|
-D "BINARY_DIR=${CMAKE_BINARY_DIR}"
|
||||||
|
-D "USER_CMAKECACHE=${SIMDJSON_USER_CMAKECACHE}"
|
||||||
|
-P "${PROJECT_SOURCE_DIR}/cmake/simdjson-user-cmakecache.cmake"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
# Setup tests
|
||||||
|
enable_testing()
|
||||||
|
# So we can build just tests with "make all_tests"
|
||||||
|
add_custom_target(all_tests)
|
||||||
|
|
||||||
|
add_subdirectory(windows)
|
||||||
|
add_subdirectory(dependencies) ## This needs to be before tools because of cxxopts
|
||||||
|
add_subdirectory(tools) ## This needs to be before tests because of cxxopts
|
||||||
|
|
||||||
|
# Data: jsonexamples is left with only the bare essential.
|
||||||
|
# most of the data has been moved to https://github.com/simdjson/simdjson-data
|
||||||
|
add_subdirectory(jsonexamples)
|
||||||
|
|
||||||
|
|
||||||
|
add_subdirectory(singleheader)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compile tools / tests / benchmarks
|
# Compile tools / tests / benchmarks
|
||||||
#
|
#
|
||||||
if(NOT(SIMDJSON_JUST_LIBRARY))
|
add_subdirectory(tests)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(examples)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(benchmark)
|
||||||
add_subdirectory(benchmark)
|
add_subdirectory(fuzz)
|
||||||
add_subdirectory(fuzz)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Source files should be just ASCII
|
# Source files should be just ASCII
|
||||||
@@ -76,29 +224,59 @@ endif()
|
|||||||
find_program(FIND find)
|
find_program(FIND find)
|
||||||
find_program(FILE file)
|
find_program(FILE file)
|
||||||
find_program(GREP grep)
|
find_program(GREP grep)
|
||||||
if((FIND) AND (FILE) AND (GREP))
|
if(FIND AND FILE AND GREP)
|
||||||
add_test(
|
add_test(
|
||||||
NAME "just_ascii"
|
NAME just_ascii
|
||||||
COMMAND sh -c "${FIND} include src windows tools singleheader tests examples benchmark -path benchmark/checkperf-reference -prune -name '*.h' -o -name '*.cpp' -type f -exec ${FILE} '{}' \; |${GREP} -v ASCII || exit 0 && exit 1"
|
COMMAND sh -c "\
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
${FIND} include src windows tools singleheader tests examples benchmark \
|
||||||
)
|
-path benchmark/checkperf-reference -prune -name '*.h' -o -name '*.cpp' \
|
||||||
|
-type f -exec ${FILE} '{}' \; | ${GREP} -qv ASCII || exit 0 && exit 1"
|
||||||
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
##
|
||||||
#
|
## In systems like R, libraries must not use stderr or abort to be acceptable.
|
||||||
# CPack
|
## Thus we make it a hard rule that one is not allowed to call abort or stderr.
|
||||||
#
|
## The sanitized builds are allowed to abort.
|
||||||
set(CPACK_PACKAGE_VENDOR "Daniel Lemire")
|
##
|
||||||
set(CPACK_PACKAGE_CONTACT "lemire@gmail.com")
|
if(NOT SIMDJSON_SANITIZE)
|
||||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Parsing gigabytes of JSON per second")
|
find_program(GREP grep)
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
|
find_program(NM nm)
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
|
if((NOT GREP) OR (NOT NM))
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
|
message("grep and nm are unavailable on this system.")
|
||||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
else()
|
||||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
add_test(
|
||||||
|
NAME "avoid_abort"
|
||||||
set(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
# Under FreeBSD, the __cxa_guard_abort symbol may appear but it is fine.
|
||||||
|
# So we want to look for <space><possibly _>abort as a test.
|
||||||
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
|
COMMAND sh -c "${NM} $<TARGET_FILE_NAME:simdjson> | ${GREP} ' _*abort' || exit 0 && exit 1"
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
include(CPack)
|
)
|
||||||
|
add_test(
|
||||||
|
NAME "avoid_cout"
|
||||||
|
COMMAND sh -c "${NM} $<TARGET_FILE_NAME:simdjson> | ${GREP} ' _*cout' || exit 0 && exit 1"
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
add_test(
|
||||||
|
NAME "avoid_cerr"
|
||||||
|
COMMAND sh -c "${NM} $<TARGET_FILE_NAME:simdjson> | ${GREP} ' _*cerr' || exit 0 && exit 1"
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
add_test(
|
||||||
|
NAME "avoid_printf"
|
||||||
|
COMMAND sh -c "${NM} $<TARGET_FILE_NAME:simdjson> | ${GREP} ' _*printf' || exit 0 && exit 1"
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
add_test(
|
||||||
|
NAME "avoid_stdout"
|
||||||
|
COMMAND sh -c "${NM} $<TARGET_FILE_NAME:simdjson> | ${GREP} stdout || exit 0 && exit 1"
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
add_test(
|
||||||
|
NAME "avoid_stderr"
|
||||||
|
COMMAND sh -c "${NM} $<TARGET_FILE_NAME:simdjson> | ${GREP} stderr || exit 0 && exit 1"
|
||||||
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|||||||
+5
-5
@@ -62,14 +62,14 @@ Pull Requests
|
|||||||
|
|
||||||
Pull requests are always invited. However, we ask that you follow these guidelines:
|
Pull requests are always invited. However, we ask that you follow these guidelines:
|
||||||
|
|
||||||
- It is wiser to discuss your ideas first as part of an issue before you start coding. If you omit this step and code first, be prepare to have your code receive scrutiny and be dropped.
|
- It is wise to discuss your ideas first as part of an issue before you start coding. If you omit this step and code first, be prepared to have your code receive scrutiny and be dropped.
|
||||||
- Users should provide a rationale for their changes. Does it improve performance? Does it add a feature? Does it improve maintainability? Does fix a bug? This must be explicitly stated as part of the pull request. Do not propose changes based on taste or intuition. We do not delegate programming to tools: that some tool suggested a code change is not reason enough to change the code.
|
- Users should provide a rationale for their changes. Does it improve performance? Does it add a feature? Does it improve maintainability? Does it fix a bug? This must be explicitly stated as part of the pull request. Do not propose changes based on taste or intuition. We do not delegate programming to tools: that some tool suggested a code change is not reason enough to change the code.
|
||||||
1. When your code improves performance, please document the gains with a benchmark using hard numbers.
|
1. When your code improves performance, please document the gains with a benchmark using hard numbers.
|
||||||
2. If your code fixes a bug, please be either fix a failing test, or propose a new test.
|
2. If your code fixes a bug, please either fix a failing test, or propose a new test.
|
||||||
3. Other types of changes must be clearly motivated. We openly discourage changes with no identifiable benefits.
|
3. Other types of changes must be clearly motivated. We openly discourage changes with no identifiable benefits.
|
||||||
- Changes should be focused and minimal. You should change as few lines of code as possible. Please do not reformat or touch files needlessly.
|
- Changes should be focused and minimal. You should change as few lines of code as possible. Please do not reformat or touch files needlessly.
|
||||||
- New features must be accompanied of new tests, in general.
|
- New features must be accompanied by new tests, in general.
|
||||||
- Your code should pass our continuous-integration tests. It is your responsability to ensure that your proposal pass the tests. We do not merge pull requests that would break our build.
|
- Your code should pass our continuous-integration tests. It is your responsibility to ensure that your proposal pass the tests. We do not merge pull requests that would break our build.
|
||||||
- An exception to this would be changes to non-code files, such as documentation and assets, or trivial changes to code, such as comments, where it is encouraged to explicitly ask for skipping a CI run using the `[skip ci]` prefix in your Pull Request title **and** in the first line of the most recent commit in a push. Example for such a commit: `[skip ci] Fixed typo in power_of_ten's docs`
|
- An exception to this would be changes to non-code files, such as documentation and assets, or trivial changes to code, such as comments, where it is encouraged to explicitly ask for skipping a CI run using the `[skip ci]` prefix in your Pull Request title **and** in the first line of the most recent commit in a push. Example for such a commit: `[skip ci] Fixed typo in power_of_ten's docs`
|
||||||
This benefits the project in such a way that the CI pipeline is not burdened by running jobs on changes that don't change any behavior in the code, which reduces wait times for other Pull Requests that do change behavior and require testing.
|
This benefits the project in such a way that the CI pipeline is not burdened by running jobs on changes that don't change any behavior in the code, which reduces wait times for other Pull Requests that do change behavior and require testing.
|
||||||
|
|
||||||
|
|||||||
@@ -36,5 +36,10 @@ Nong Li
|
|||||||
Furkan Taşkale
|
Furkan Taşkale
|
||||||
Brendan Knapp
|
Brendan Knapp
|
||||||
Danila Kutenin
|
Danila Kutenin
|
||||||
|
Pavel Pavlov
|
||||||
|
Hao Chen
|
||||||
|
Nicolas Boyer
|
||||||
|
Kim Walisch and Jatin Bhateja (AVX-512 bitset decoder)
|
||||||
|
Fangzheng Zhang and Weiqiang Wan (AVX-512 kernel)
|
||||||
# if you have contributed to the project and your name does not
|
# if you have contributed to the project and your name does not
|
||||||
# appear in this list, please let us know!
|
# appear in this list, please let us know!
|
||||||
|
|||||||
-88
@@ -1,88 +0,0 @@
|
|||||||
###
|
|
||||||
#
|
|
||||||
# Though simdjson requires only commonly available compilers and tools, it can
|
|
||||||
# be convenient to build it and test it inside a docker container: it makes it
|
|
||||||
# possible to test and benchmark simdjson under even relatively out-of-date
|
|
||||||
# Linux servers. It should also work under macOS and Windows, though not
|
|
||||||
# at native speeds, maybe.
|
|
||||||
#
|
|
||||||
# Assuming that you have a working docker server, this file
|
|
||||||
# allows you to build, test and benchmark simdjson.
|
|
||||||
#
|
|
||||||
# We build the library and associated files in the dockerbuild subdirectory.
|
|
||||||
# It may be necessary to delete it before creating the image:
|
|
||||||
#
|
|
||||||
# rm -r -f dockerbuild
|
|
||||||
#
|
|
||||||
# The need to delete the directory has nothing to do with docker per se: it is
|
|
||||||
# simply cleaner in CMake to start from a fresh directory. This is important: if you
|
|
||||||
# reuse the same directory with different configurations, you may get broken builds.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Then you can build the image as follows:
|
|
||||||
#
|
|
||||||
# docker build -t simdjson --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) .
|
|
||||||
#
|
|
||||||
# Please note that the image does not contain a copy of the code. However, the image will contain the
|
|
||||||
# the compiler and the build system. This means that if you change the source code, after you have built
|
|
||||||
# the image, you won't need to rebuild the image. In fact, unless you want to try a different compiler, you
|
|
||||||
# do not need to ever rebuild the image, even if you do a lot of work on the source code.
|
|
||||||
#
|
|
||||||
# We specify the users to avoid having files owned by a privileged user (root) in our directory. Some
|
|
||||||
# people like to run their machine as the "root" user. We do not think it is cool.
|
|
||||||
#
|
|
||||||
# Then you need to build the project:
|
|
||||||
#
|
|
||||||
# docker run -v $(pwd):/project:Z simdjson
|
|
||||||
#
|
|
||||||
# Should you change a source file, you may need to call this command again. Because the output
|
|
||||||
# files are persistent between calls to this command (they reside in the dockerbuild directory),
|
|
||||||
# this command can be fast.
|
|
||||||
#
|
|
||||||
# Next you can test it as follows:
|
|
||||||
#
|
|
||||||
# docker run -it -v $(pwd):/project:Z simdjson sh -c "cd dockerbuild && ctest . --output-on-failure -LE explicitonly"
|
|
||||||
#
|
|
||||||
# The run the complete tests requires you to have built all of simdjson.
|
|
||||||
#
|
|
||||||
# Building all of simdjson takes a long time. Instead, you can build just one target:
|
|
||||||
#
|
|
||||||
# docker run -it -v $(pwd):/project:Z simdjson sh -c "[ -d dockerbuild ] || mkdir dockerbuild && cd dockerbuild && cmake .. && cmake --build . --target parse"
|
|
||||||
#
|
|
||||||
# Note that it is safe to remove dockerbuild before call the previous command, as the repository gets rebuild. It is also possible, by changing the command, to use a different directory name.
|
|
||||||
#
|
|
||||||
# You can run performance tests:
|
|
||||||
#
|
|
||||||
# docker run -it --privileged -v $(pwd):/project:Z simdjson sh -c "cd dockerbuild && for i in ../jsonexamples/*.json; do echo \$i; ./benchmark/parse \$i; done"
|
|
||||||
#
|
|
||||||
# The "--privileged" is recommended so you can get performance counters under Linux.
|
|
||||||
#
|
|
||||||
# You can also grab a fresh copy of simdjson and rebuild it, to make comparisons:
|
|
||||||
#
|
|
||||||
# docker run -it -v $(pwd):/project:Z simdjson sh -c "git clone https://github.com/simdjson/simdjson.git && cd simdjson && mkdir build && cd build && cmake .. && cmake --build . --target parse "
|
|
||||||
#
|
|
||||||
# Then you can run comparisons:
|
|
||||||
#
|
|
||||||
# docker run -it --privileged -v $(pwd):/project:Z simdjson sh -c "for i in jsonexamples/*.json; do echo \$i; dockerbuild/benchmark/parse \$i| grep GB| head -n 1; simdjson/build/benchmark/parse \$i | grep GB |head -n 1; done"
|
|
||||||
#
|
|
||||||
####
|
|
||||||
FROM ubuntu:20.10
|
|
||||||
################
|
|
||||||
# We would prefer to use the conan io images but they do not support 64-bit ARM? The small gcc images appear to
|
|
||||||
# be broken on ARM.
|
|
||||||
# Furthermore, we would not expect users to frequently rebuild the container, so using ubuntu is probably fine.
|
|
||||||
###############
|
|
||||||
ARG USER_ID
|
|
||||||
ARG GROUP_ID
|
|
||||||
RUN apt-get update -qq
|
|
||||||
RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata
|
|
||||||
RUN apt-get install -y cmake g++ git
|
|
||||||
RUN mkdir project
|
|
||||||
|
|
||||||
RUN addgroup --gid $GROUP_ID user; exit 0
|
|
||||||
RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user; exit 0
|
|
||||||
USER user
|
|
||||||
RUN gcc --version
|
|
||||||
WORKDIR /project
|
|
||||||
|
|
||||||
CMD ["sh","-c","[ -d dockerbuild ] || mkdir dockerbuild && cd dockerbuild && cmake .. && cmake --build . "]
|
|
||||||
@@ -38,7 +38,7 @@ PROJECT_NAME = simdjson
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = "0.9.4"
|
PROJECT_NUMBER = "2.0.4"
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
|
|||||||
+27
-15
@@ -32,6 +32,18 @@ Stage 1 also does unicode validation.
|
|||||||
|
|
||||||
Stage 2 handles all of the rest: number parsings, recognizing atoms like true, false, null, and so forth.
|
Stage 2 handles all of the rest: number parsings, recognizing atoms like true, false, null, and so forth.
|
||||||
|
|
||||||
|
Developer mode
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Build system targets that are only useful for developers of the simdjson
|
||||||
|
library are behind the `SIMDJSON_DEVELOPER_MODE` option. Enabling this option
|
||||||
|
makes tests, examples, benchmarks and other developer targets available. Not
|
||||||
|
enabling this option means that you are a consumer of simdjson and thus you
|
||||||
|
only get the library targets and options.
|
||||||
|
|
||||||
|
Developer mode is forced to be on when the `CI` environment variable is set to
|
||||||
|
a value that CMake recognizes as "on", which is set to `true` in all of the CI
|
||||||
|
workflows used by simdjson.
|
||||||
|
|
||||||
Directory Structure and Source
|
Directory Structure and Source
|
||||||
------------------------------
|
------------------------------
|
||||||
@@ -74,19 +86,19 @@ Other important files and directories:
|
|||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
|
||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
benchmark/parse ../jsonexamples/twitter.json
|
benchmark/dom/parse ../jsonexamples/twitter.json
|
||||||
```
|
```
|
||||||
The last line becomes `./benchmark/Release/parse.exe ../jsonexample/twitter.json` under Windows. You may also use Google Benchmark:
|
The last line becomes `./benchmark/Release/parse.exe ../jsonexample/twitter.json` under Windows. You may also use Google Benchmark:
|
||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
|
||||||
cmake --build . --target bench_parse_call --config Release
|
cmake --build . --target bench_parse_call --config Release
|
||||||
./benchmark/bench_parse_call
|
./benchmark/bench_parse_call
|
||||||
```
|
```
|
||||||
The last line becomes `./benchmark/Release/bench_parse_call.exe` under Windows. Under Windows, you can also build with the clang compiler by adding `-T ClangCL` to the call to `cmake ..`: `cmake .. - TClangCL`.
|
The last line becomes `./benchmark/Release/bench_parse_call.exe` under Windows. Under Windows, you can also build with the clang compiler by adding `-T ClangCL` to the call to `cmake ..`: `cmake -T ClangCL ..`.
|
||||||
* **fuzz:** The source for fuzz testing. This lets us explore important edge and middle cases
|
* **fuzz:** The source for fuzz testing. This lets us explore important edge and middle cases
|
||||||
* **fuzz:** The source for fuzz testing. This lets us explore important edge and middle cases
|
* **fuzz:** The source for fuzz testing. This lets us explore important edge and middle cases
|
||||||
automatically, and is run in CI.
|
automatically, and is run in CI.
|
||||||
@@ -147,7 +159,7 @@ processor.
|
|||||||
|
|
||||||
At this point, we are require to use one of two main strategies.
|
At this point, we are require to use one of two main strategies.
|
||||||
|
|
||||||
1. On POSIX systems, the main compilers (LLVM clang, GNU gcc) allow us to use any intrinsic function after including the header, but they fail to inline the resulting instruction if the target processor does not support them. Because we compile for a generic processor, we would not be able to use most intrinsic functions. Thankfully, more recent versions of these compilers allow us to flag a region of code with a specific target, so that we can compile only some of the code with support for advanced instructions. Thus in our C++, one might notice macros like `TARGET_HASWELL`. It is then our responsability, at runtime, to only run the regions of code (that we call kernels) matching the properties of the runtime processor. The benefit of this approach is that the compiler not only let us use intrinsic functions, but it can also optimize the rest of the code in the kernel with advanced instructions we enabled.
|
1. On POSIX systems, the main compilers (LLVM clang, GNU gcc) allow us to use any intrinsic function after including the header, but they fail to inline the resulting instruction if the target processor does not support them. Because we compile for a generic processor, we would not be able to use most intrinsic functions. Thankfully, more recent versions of these compilers allow us to flag a region of code with a specific target, so that we can compile only some of the code with support for advanced instructions. Thus in our C++, one might notice macros like `TARGET_HASWELL`. It is then our responsibility, at runtime, to only run the regions of code (that we call kernels) matching the properties of the runtime processor. The benefit of this approach is that the compiler not only let us use intrinsic functions, but it can also optimize the rest of the code in the kernel with advanced instructions we enabled.
|
||||||
|
|
||||||
2. Under Visual Studio, the problem is somewhat simpler. Visual Studio will not only provide the intrinsic functions, but it will also allow us to use them. They will compile just fine. It is at runtime that they may cause a crash. So we do not need to mark regions of code for compilation toward advanced processors (e.g., with `TARGET_HASWELL` macros). The downside of the Visual Studio approach is that the compiler is not allowed to use advanced instructions others than those we specify. In principle, this means that Visual Studio has weaker optimization opportunities.
|
2. Under Visual Studio, the problem is somewhat simpler. Visual Studio will not only provide the intrinsic functions, but it will also allow us to use them. They will compile just fine. It is at runtime that they may cause a crash. So we do not need to mark regions of code for compilation toward advanced processors (e.g., with `TARGET_HASWELL` macros). The downside of the Visual Studio approach is that the compiler is not allowed to use advanced instructions others than those we specify. In principle, this means that Visual Studio has weaker optimization opportunities.
|
||||||
|
|
||||||
@@ -168,7 +180,7 @@ systematically regenerated on releases. To ensure you have the latest code, you
|
|||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
|
||||||
cmake --build . # needed, because currently dependencies do not work fully for the amalgamate target
|
cmake --build . # needed, because currently dependencies do not work fully for the amalgamate target
|
||||||
cmake --build . --target amalgamate
|
cmake --build . --target amalgamate
|
||||||
```
|
```
|
||||||
@@ -209,31 +221,31 @@ Building: While in the project repository, do the following:
|
|||||||
```
|
```
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
|
||||||
cmake --build .
|
cmake --build .
|
||||||
ctest
|
ctest
|
||||||
```
|
```
|
||||||
|
|
||||||
CMake will build a library. By default, it builds a shared library (e.g., libsimdjson.so on Linux).
|
CMake will build a library. By default, it builds a static library (e.g., libsimdjson.a on Linux).
|
||||||
|
|
||||||
You can build a static library:
|
You can build a shared library:
|
||||||
|
|
||||||
```
|
```
|
||||||
mkdir buildstatic
|
mkdir buildshared
|
||||||
cd buildstatic
|
cd buildshared
|
||||||
cmake -DSIMDJSON_BUILD_STATIC=ON ..
|
cmake -D BUILD_SHARED_LIBS=ON -D SIMDJSON_DEVELOPER_MODE=ON ..
|
||||||
cmake --build .
|
cmake --build .
|
||||||
ctest
|
ctest
|
||||||
```
|
```
|
||||||
|
|
||||||
In some cases, you may want to specify your compiler, especially if the default compiler on your system is too old. You need to tell cmake which compiler you wish to use by setting the CC and CXX variables. Under bash, you can do so with commands such as `export CC=gcc-7` and `export CXX=g++-7`. You can also do it as part of the `cmake` command: `cmake .. -DCMAKE_CXX_COMPILER=g++`. You may proceed as follows:
|
In some cases, you may want to specify your compiler, especially if the default compiler on your system is too old. You need to tell cmake which compiler you wish to use by setting the CC and CXX variables. Under bash, you can do so with commands such as `export CC=gcc-7` and `export CXX=g++-7`. You can also do it as part of the `cmake` command: `cmake -DCMAKE_CXX_COMPILER=g++ ..`. You may proceed as follows:
|
||||||
|
|
||||||
```
|
```
|
||||||
brew install gcc@8
|
brew install gcc@8
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
export CXX=g++-8 CC=gcc-8
|
export CXX=g++-8 CC=gcc-8
|
||||||
cmake ..
|
cmake -D SIMDJSON_DEVELOPER_MODE=ON ..
|
||||||
cmake --build .
|
cmake --build .
|
||||||
ctest
|
ctest
|
||||||
```
|
```
|
||||||
@@ -269,7 +281,7 @@ Furthermore, if you have installed LLVM clang on Windows, for example as a compo
|
|||||||
|
|
||||||
- `mkdir build`
|
- `mkdir build`
|
||||||
- `cd build`
|
- `cd build`
|
||||||
- `cmake .. -T ClangCL`
|
- `cmake -T ClangCL ..`
|
||||||
- `cmake --build . -config Release`
|
- `cmake --build . -config Release`
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&q=proj%3Asimdjson&can=2)
|
|
||||||
/badge.svg)
|
/badge.svg)
|
||||||
[/badge.svg)](https://simdjson.org/plots.html)
|
[/badge.svg)](https://simdjson.org/plots.html)
|
||||||

|

|
||||||

|

|
||||||
[![][license img]][license] [](https://simdjson.org/api/0.9.0/index.html)
|
[![][license img]][license] [](https://simdjson.org/api/2.0.0/index.html)
|
||||||
|
|
||||||
simdjson : Parsing gigabytes of JSON per second
|
simdjson : Parsing gigabytes of JSON per second
|
||||||
===============================================
|
===============================================
|
||||||
@@ -27,7 +27,6 @@ Table of Contents
|
|||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
* [Quick Start](#quick-start)
|
* [Quick Start](#quick-start)
|
||||||
* [On Demand](#on-demand)
|
|
||||||
* [Documentation](#documentation)
|
* [Documentation](#documentation)
|
||||||
* [Performance results](#performance-results)
|
* [Performance results](#performance-results)
|
||||||
* [Real-world usage](#real-world-usage)
|
* [Real-world usage](#real-world-usage)
|
||||||
@@ -54,6 +53,7 @@ The simdjson library is easily consumable with a single .h and .cpp file.
|
|||||||
2. Create `quickstart.cpp`:
|
2. Create `quickstart.cpp`:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
|
#include <iostream>
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
using namespace simdjson;
|
using namespace simdjson;
|
||||||
int main(void) {
|
int main(void) {
|
||||||
@@ -79,7 +79,7 @@ Usage documentation is available:
|
|||||||
* [Performance](doc/performance.md) shows some more advanced scenarios and how to tune for them.
|
* [Performance](doc/performance.md) shows some more advanced scenarios and how to tune for them.
|
||||||
* [Implementation Selection](doc/implementation-selection.md) describes runtime CPU detection and
|
* [Implementation Selection](doc/implementation-selection.md) describes runtime CPU detection and
|
||||||
how you can work with it.
|
how you can work with it.
|
||||||
* [API](https://simdjson.org/api/0.9.0/annotated.html) contains the automatically generated API documentation.
|
* [API](https://simdjson.org/api/1.0.0/annotated.html) contains the automatically generated API documentation.
|
||||||
|
|
||||||
Performance results
|
Performance results
|
||||||
-------------------
|
-------------------
|
||||||
@@ -137,6 +137,8 @@ We distinguish between "bindings" (which just wrap the C++ code) and a port to a
|
|||||||
- [simdjson-go](https://github.com/minio/simdjson-go): Go port using Golang assembly.
|
- [simdjson-go](https://github.com/minio/simdjson-go): Go port using Golang assembly.
|
||||||
- [rcppsimdjson](https://github.com/eddelbuettel/rcppsimdjson): R bindings.
|
- [rcppsimdjson](https://github.com/eddelbuettel/rcppsimdjson): R bindings.
|
||||||
- [simdjson_erlang](https://github.com/ChomperT/simdjson_erlang): erlang bindings.
|
- [simdjson_erlang](https://github.com/ChomperT/simdjson_erlang): erlang bindings.
|
||||||
|
- [lua-simdjson](https://github.com/FourierTransformer/lua-simdjson): lua bindings.
|
||||||
|
- [hermes-json](https://hackage.haskell.org/package/hermes-json): haskell bindings.
|
||||||
|
|
||||||
|
|
||||||
About simdjson
|
About simdjson
|
||||||
@@ -152,13 +154,13 @@ and implementation of simdjson is in our research article:
|
|||||||
|
|
||||||
We have an in-depth paper focused on the UTF-8 validation:
|
We have an in-depth paper focused on the UTF-8 validation:
|
||||||
|
|
||||||
- John Keiser, Daniel Lemire, [Validating UTF-8 In Less Than One Instruction Per Byte](https://arxiv.org/abs/2010.03090), Software: Practice & Experience (to appear)
|
- John Keiser, Daniel Lemire, [Validating UTF-8 In Less Than One Instruction Per Byte](https://arxiv.org/abs/2010.03090), Software: Practice & Experience 51 (5), 2021.
|
||||||
|
|
||||||
We also have an informal [blog post providing some background and context](https://branchfree.org/2019/02/25/paper-parsing-gigabytes-of-json-per-second/).
|
We also have an informal [blog post providing some background and context](https://branchfree.org/2019/02/25/paper-parsing-gigabytes-of-json-per-second/).
|
||||||
|
|
||||||
For the video inclined, <br />
|
For the video inclined, <br />
|
||||||
[](http://www.youtube.com/watch?v=wlvKAT7SZIQ)<br />
|
[](http://www.youtube.com/watch?v=wlvKAT7SZIQ)<br />
|
||||||
(it was the best voted talk, we're kinda proud of it).
|
(It was the best voted talk, we're kinda proud of it.)
|
||||||
|
|
||||||
Funding
|
Funding
|
||||||
-------
|
-------
|
||||||
@@ -182,4 +184,8 @@ This code is made available under the [Apache License 2.0](https://www.apache.or
|
|||||||
|
|
||||||
Under Windows, we build some tools using the windows/dirent_portable.h file (which is outside our library code): it under the liberal (business-friendly) MIT license.
|
Under Windows, we build some tools using the windows/dirent_portable.h file (which is outside our library code): it under the liberal (business-friendly) MIT license.
|
||||||
|
|
||||||
For compilers that do not support [C++17](https://en.wikipedia.org/wiki/C%2B%2B17), we bundle the string-view library which is published under the Boost license (http://www.boost.org/LICENSE_1_0.txt). Like the Apache license, the Boost license is a permissive license allowing commercial redistribution.
|
For compilers that do not support [C++17](https://en.wikipedia.org/wiki/C%2B%2B17), we bundle the string-view library which is published under the [Boost license](http://www.boost.org/LICENSE_1_0.txt). Like the Apache license, the Boost license is a permissive license allowing commercial redistribution.
|
||||||
|
|
||||||
|
For efficient number serialization, we bundle Florian Loitsch's implementation of the Grisu2 algorithm for binary to decimal floating-point numbers. The implementation was slightly modified by JSON for Modern C++ library. Both Florian Loitsch's implementation and JSON for Modern C++ are provided under the MIT license.
|
||||||
|
|
||||||
|
For runtime dispatching, we use some code from the PyTorch project licensed under 3-clause BSD.
|
||||||
|
|||||||
@@ -1,20 +1,12 @@
|
|||||||
|
add_subdirectory(dom)
|
||||||
|
|
||||||
|
|
||||||
include_directories( . linux )
|
include_directories( . linux )
|
||||||
link_libraries(simdjson-windows-headers test-data)
|
link_libraries(simdjson-windows-headers test-data)
|
||||||
link_libraries(simdjson simdjson-flags)
|
link_libraries(simdjson)
|
||||||
|
|
||||||
add_executable(benchfeatures benchfeatures.cpp)
|
add_executable(benchfeatures benchfeatures.cpp)
|
||||||
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
|
add_executable(get_corpus_benchmark get_corpus_benchmark.cpp)
|
||||||
add_executable(perfdiff perfdiff.cpp)
|
|
||||||
add_executable(parse parse.cpp)
|
|
||||||
add_executable(parse_stream parse_stream.cpp)
|
|
||||||
add_executable(statisticalmodel statisticalmodel.cpp)
|
|
||||||
|
|
||||||
add_executable(parse_noutf8validation parse.cpp)
|
|
||||||
target_compile_definitions(parse_noutf8validation PRIVATE SIMDJSON_SKIPUTF8VALIDATION)
|
|
||||||
add_executable(parse_nonumberparsing parse.cpp)
|
|
||||||
target_compile_definitions(parse_nonumberparsing PRIVATE SIMDJSON_SKIPNUMBERPARSING)
|
|
||||||
add_executable(parse_nostringparsing parse.cpp)
|
|
||||||
target_compile_definitions(parse_nostringparsing PRIVATE SIMDJSON_SKIPSTRINGPARSING)
|
|
||||||
|
|
||||||
if (TARGET benchmark::benchmark)
|
if (TARGET benchmark::benchmark)
|
||||||
link_libraries(benchmark::benchmark)
|
link_libraries(benchmark::benchmark)
|
||||||
@@ -37,5 +29,3 @@ if (TARGET benchmark::benchmark)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# deliberately disabling.
|
|
||||||
# include(checkperf.cmake)
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
# From the ROOT, run:
|
|
||||||
# docker build -t simdjsonbench -f benchmark/Dockerfile . && docker run --privileged -t simdjsonbench
|
|
||||||
FROM gcc:8.3
|
|
||||||
|
|
||||||
# # Build latest
|
|
||||||
# ENV latest_release=v0.2.1
|
|
||||||
# WORKDIR /usr/src/$latest_release/
|
|
||||||
# RUN git clone --depth 1 https://github.com/lemire/simdjson/ -b $latest_release .
|
|
||||||
# RUN make parse
|
|
||||||
|
|
||||||
# # Build master
|
|
||||||
# WORKDIR /usr/src/master/
|
|
||||||
# RUN git clone --depth 1 https://github.com/lemire/simdjson/ .
|
|
||||||
# RUN make parse
|
|
||||||
|
|
||||||
# Build the current source
|
|
||||||
COPY . /usr/src/current/
|
|
||||||
WORKDIR /usr/src/current/
|
|
||||||
RUN make checkperf
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "json_benchmark/file_runner.h"
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace amazon_cellphones {
|
||||||
|
|
||||||
|
const bool UNTHREADED = false;
|
||||||
|
const bool THREADED = true;
|
||||||
|
|
||||||
|
using namespace json_benchmark;
|
||||||
|
|
||||||
|
struct brand {
|
||||||
|
double cumulative_rating;
|
||||||
|
uint64_t reviews_count;
|
||||||
|
simdjson_really_inline bool operator==(const brand &other) const {
|
||||||
|
return cumulative_rating == other.cumulative_rating &&
|
||||||
|
reviews_count == other.reviews_count;
|
||||||
|
}
|
||||||
|
simdjson_really_inline bool operator!=(const brand &other) const { return !(*this == other); }
|
||||||
|
};
|
||||||
|
|
||||||
|
simdjson_unused static std::ostream &operator<<(std::ostream &o, const brand &b) {
|
||||||
|
o << "cumulative_rating: " << b.cumulative_rating << std::endl;
|
||||||
|
o << "reviews_count: " << b.reviews_count << std::endl;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StringType>
|
||||||
|
simdjson_unused static std::ostream &operator<<(std::ostream &o, const std::pair<const StringType, brand> &p) {
|
||||||
|
o << "brand: " << p.first << std::endl;
|
||||||
|
o << p.second;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename I>
|
||||||
|
struct runner : public file_runner<I> {
|
||||||
|
std::map<typename I::StringType, brand> result{};
|
||||||
|
|
||||||
|
bool setup(benchmark::State &state) {
|
||||||
|
return this->load_json(state, AMAZON_CELLPHONES_NDJSON);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool before_run(benchmark::State &state) {
|
||||||
|
if (!file_runner<I>::before_run(state)) { return false; }
|
||||||
|
result.clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool run(benchmark::State &) {
|
||||||
|
return this->implementation.run(this->json, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename R>
|
||||||
|
bool diff(benchmark::State &state, runner<R> &reference) {
|
||||||
|
return diff_results(state, result, reference.result, diff_flags::NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t items_per_iteration() {
|
||||||
|
return result.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<bool threaded>
|
||||||
|
struct simdjson_dom;
|
||||||
|
|
||||||
|
template<typename I> simdjson_really_inline static void amazon_cellphones(benchmark::State &state) {
|
||||||
|
run_json_benchmark<runner<I>, runner<simdjson_dom<UNTHREADED>>>(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace amazon_cellphones
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
#include "amazon_cellphones.h"
|
||||||
|
|
||||||
|
namespace amazon_cellphones {
|
||||||
|
|
||||||
|
using namespace simdjson;
|
||||||
|
|
||||||
|
template<bool threaded>
|
||||||
|
struct simdjson_dom {
|
||||||
|
using StringType = std::string;
|
||||||
|
|
||||||
|
dom::parser parser{};
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::map<StringType, brand> &result) {
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
parser.threaded = threaded;
|
||||||
|
#endif
|
||||||
|
auto stream = parser.parse_many(json);
|
||||||
|
auto i = stream.begin();
|
||||||
|
++i; // Skip first line
|
||||||
|
for (;i != stream.end(); ++i) {
|
||||||
|
auto doc = *i;
|
||||||
|
StringType copy(std::string_view(doc.at(1)));
|
||||||
|
auto x = result.find(copy);
|
||||||
|
if (x == result.end()) { // If key not found, add new key
|
||||||
|
result.emplace(copy, amazon_cellphones::brand{
|
||||||
|
double(doc.at(5)) * uint64_t(doc.at(7)),
|
||||||
|
uint64_t(doc.at(7))
|
||||||
|
});
|
||||||
|
} else { // Otherwise, update key data
|
||||||
|
x->second.cumulative_rating += double(doc.at(5)) * uint64_t(doc.at(7));
|
||||||
|
x->second.reviews_count += uint64_t(doc.at(7));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK_TEMPLATE(amazon_cellphones, simdjson_dom<UNTHREADED>)->UseManualTime();
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
BENCHMARK_TEMPLATE(amazon_cellphones, simdjson_dom<THREADED>)->UseManualTime();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace amazon_cellphones
|
||||||
|
|
||||||
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
#include "amazon_cellphones.h"
|
||||||
|
|
||||||
|
namespace amazon_cellphones {
|
||||||
|
|
||||||
|
using namespace simdjson;
|
||||||
|
|
||||||
|
template<bool threaded>
|
||||||
|
struct simdjson_ondemand {
|
||||||
|
using StringType = std::string;
|
||||||
|
|
||||||
|
ondemand::parser parser{};
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::map<StringType, brand> &result) {
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
parser.threaded = threaded;
|
||||||
|
#endif
|
||||||
|
ondemand::document_stream stream = parser.iterate_many(json);
|
||||||
|
ondemand::document_stream::iterator i = stream.begin();
|
||||||
|
++i; // Skip first line
|
||||||
|
for (;i != stream.end(); ++i) {
|
||||||
|
auto doc = *i;
|
||||||
|
size_t index{0};
|
||||||
|
StringType copy;
|
||||||
|
double rating;
|
||||||
|
uint64_t reviews;
|
||||||
|
for ( auto value : doc ) {
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
copy = StringType(std::string_view(value));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
rating = double(value);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
reviews = uint64_t(value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto x = result.find(copy);
|
||||||
|
if (x == result.end()) { // If key not found, add new key
|
||||||
|
result.emplace(copy, amazon_cellphones::brand{
|
||||||
|
rating * reviews,
|
||||||
|
reviews
|
||||||
|
});
|
||||||
|
} else { // Otherwise, update key data
|
||||||
|
x->second.cumulative_rating += rating * reviews;
|
||||||
|
x->second.reviews_count += reviews;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK_TEMPLATE(amazon_cellphones, simdjson_ondemand<UNTHREADED>)->UseManualTime();
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
BENCHMARK_TEMPLATE(amazon_cellphones, simdjson_ondemand<THREADED>)->UseManualTime();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace amazon_cellphones
|
||||||
|
|
||||||
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
|
#include <iostream>
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,20 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
|
|||||||
|
|
||||||
SIMDJSON_POP_DISABLE_WARNINGS
|
SIMDJSON_POP_DISABLE_WARNINGS
|
||||||
|
|
||||||
|
#include "amazon_cellphones/simdjson_dom.h"
|
||||||
|
#include "amazon_cellphones/simdjson_ondemand.h"
|
||||||
|
|
||||||
|
#include "large_amazon_cellphones/simdjson_dom.h"
|
||||||
|
#include "large_amazon_cellphones/simdjson_ondemand.h"
|
||||||
|
|
||||||
#include "partial_tweets/simdjson_dom.h"
|
#include "partial_tweets/simdjson_dom.h"
|
||||||
#include "partial_tweets/simdjson_ondemand.h"
|
#include "partial_tweets/simdjson_ondemand.h"
|
||||||
#include "partial_tweets/yyjson.h"
|
#include "partial_tweets/yyjson.h"
|
||||||
#include "partial_tweets/sajson.h"
|
#include "partial_tweets/sajson.h"
|
||||||
#include "partial_tweets/rapidjson.h"
|
#include "partial_tweets/rapidjson.h"
|
||||||
|
#include "partial_tweets/rapidjson_sax.h"
|
||||||
#include "partial_tweets/nlohmann_json.h"
|
#include "partial_tweets/nlohmann_json.h"
|
||||||
|
#include "partial_tweets/nlohmann_json_sax.h"
|
||||||
|
|
||||||
#include "large_random/simdjson_dom.h"
|
#include "large_random/simdjson_dom.h"
|
||||||
#include "large_random/simdjson_ondemand.h"
|
#include "large_random/simdjson_ondemand.h"
|
||||||
@@ -39,34 +47,46 @@ SIMDJSON_POP_DISABLE_WARNINGS
|
|||||||
#include "large_random/yyjson.h"
|
#include "large_random/yyjson.h"
|
||||||
#include "large_random/sajson.h"
|
#include "large_random/sajson.h"
|
||||||
#include "large_random/rapidjson.h"
|
#include "large_random/rapidjson.h"
|
||||||
|
#include "large_random/rapidjson_sax.h"
|
||||||
#include "large_random/nlohmann_json.h"
|
#include "large_random/nlohmann_json.h"
|
||||||
|
#include "large_random/nlohmann_json_sax.h"
|
||||||
|
|
||||||
#include "kostya/simdjson_dom.h"
|
#include "kostya/simdjson_dom.h"
|
||||||
#include "kostya/simdjson_ondemand.h"
|
#include "kostya/simdjson_ondemand.h"
|
||||||
#include "kostya/yyjson.h"
|
#include "kostya/yyjson.h"
|
||||||
#include "kostya/sajson.h"
|
#include "kostya/sajson.h"
|
||||||
#include "kostya/rapidjson.h"
|
#include "kostya/rapidjson.h"
|
||||||
|
#include "kostya/rapidjson_sax.h"
|
||||||
#include "kostya/nlohmann_json.h"
|
#include "kostya/nlohmann_json.h"
|
||||||
|
#include "kostya/nlohmann_json_sax.h"
|
||||||
|
|
||||||
#include "distinct_user_id/simdjson_dom.h"
|
#include "distinct_user_id/simdjson_dom.h"
|
||||||
|
#include "distinct_user_id/simdjson_dom_json_pointer.h"
|
||||||
#include "distinct_user_id/simdjson_ondemand.h"
|
#include "distinct_user_id/simdjson_ondemand.h"
|
||||||
|
#include "distinct_user_id/simdjson_ondemand_json_pointer.h"
|
||||||
#include "distinct_user_id/yyjson.h"
|
#include "distinct_user_id/yyjson.h"
|
||||||
#include "distinct_user_id/sajson.h"
|
#include "distinct_user_id/sajson.h"
|
||||||
#include "distinct_user_id/rapidjson.h"
|
#include "distinct_user_id/rapidjson.h"
|
||||||
|
#include "distinct_user_id/rapidjson_sax.h"
|
||||||
#include "distinct_user_id/nlohmann_json.h"
|
#include "distinct_user_id/nlohmann_json.h"
|
||||||
|
#include "distinct_user_id/nlohmann_json_sax.h"
|
||||||
|
|
||||||
#include "find_tweet/simdjson_dom.h"
|
#include "find_tweet/simdjson_dom.h"
|
||||||
#include "find_tweet/simdjson_ondemand.h"
|
#include "find_tweet/simdjson_ondemand.h"
|
||||||
#include "find_tweet/yyjson.h"
|
#include "find_tweet/yyjson.h"
|
||||||
#include "find_tweet/sajson.h"
|
#include "find_tweet/sajson.h"
|
||||||
#include "find_tweet/rapidjson.h"
|
#include "find_tweet/rapidjson.h"
|
||||||
|
#include "find_tweet/rapidjson_sax.h"
|
||||||
#include "find_tweet/nlohmann_json.h"
|
#include "find_tweet/nlohmann_json.h"
|
||||||
|
#include "find_tweet/nlohmann_json_sax.h"
|
||||||
|
|
||||||
#include "top_tweet/simdjson_dom.h"
|
#include "top_tweet/simdjson_dom.h"
|
||||||
#include "top_tweet/simdjson_ondemand.h"
|
#include "top_tweet/simdjson_ondemand.h"
|
||||||
#include "top_tweet/yyjson.h"
|
#include "top_tweet/yyjson.h"
|
||||||
#include "top_tweet/sajson.h"
|
#include "top_tweet/sajson.h"
|
||||||
#include "top_tweet/rapidjson.h"
|
#include "top_tweet/rapidjson.h"
|
||||||
|
#include "top_tweet/rapidjson_sax.h"
|
||||||
#include "top_tweet/nlohmann_json.h"
|
#include "top_tweet/nlohmann_json.h"
|
||||||
|
#include "top_tweet/nlohmann_json_sax.h"
|
||||||
|
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
|
#include <iostream>
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
using namespace simdjson;
|
using namespace simdjson;
|
||||||
using namespace benchmark;
|
using namespace benchmark;
|
||||||
@@ -10,6 +11,64 @@ const char *GSOC_JSON = SIMDJSON_BENCHMARK_DATA_DIR "gsoc-2018.json";
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void fast_minify_twitter(State& state) {
|
||||||
|
dom::parser parser;
|
||||||
|
padded_string docdata;
|
||||||
|
auto error = padded_string::load(TWITTER_JSON).get(docdata);
|
||||||
|
if(error) {
|
||||||
|
cerr << "could not parse twitter.json" << error << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::unique_ptr<char[]> buffer{new char[docdata.size()]};
|
||||||
|
|
||||||
|
size_t bytes = 0;
|
||||||
|
for (simdjson_unused auto _ : state) {
|
||||||
|
size_t new_length{}; // It will receive the minified length.
|
||||||
|
auto error = simdjson::minify(docdata.data(), docdata.size(), buffer.get(), new_length);
|
||||||
|
bytes += docdata.size();
|
||||||
|
benchmark::DoNotOptimize(error);
|
||||||
|
}
|
||||||
|
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
|
||||||
|
state.counters["Gigabytes"] = benchmark::Counter(
|
||||||
|
double(bytes), benchmark::Counter::kIsRate,
|
||||||
|
benchmark::Counter::OneK::kIs1000); // For GiB : kIs1024
|
||||||
|
state.counters["docs"] = Counter(double(state.iterations()), benchmark::Counter::kIsRate);
|
||||||
|
}
|
||||||
|
BENCHMARK(fast_minify_twitter)->Repetitions(10)->ComputeStatistics("max", [](const std::vector<double>& v) -> double {
|
||||||
|
return *(std::max_element(std::begin(v), std::end(v)));
|
||||||
|
})->DisplayAggregatesOnly(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void fast_minify_gsoc(State& state) {
|
||||||
|
dom::parser parser;
|
||||||
|
padded_string docdata;
|
||||||
|
auto error = padded_string::load(GSOC_JSON).get(docdata);
|
||||||
|
if(error) {
|
||||||
|
cerr << "could not parse gsoc-2018.json" << error << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::unique_ptr<char[]> buffer{new char[docdata.size()]};
|
||||||
|
|
||||||
|
size_t bytes = 0;
|
||||||
|
for (simdjson_unused auto _ : state) {
|
||||||
|
size_t new_length{}; // It will receive the minified length.
|
||||||
|
auto error = simdjson::minify(docdata.data(), docdata.size(), buffer.get(), new_length);
|
||||||
|
bytes += docdata.size();
|
||||||
|
benchmark::DoNotOptimize(error);
|
||||||
|
}
|
||||||
|
// Gigabyte: https://en.wikipedia.org/wiki/Gigabyte
|
||||||
|
state.counters["Gigabytes"] = benchmark::Counter(
|
||||||
|
double(bytes), benchmark::Counter::kIsRate,
|
||||||
|
benchmark::Counter::OneK::kIs1000); // For GiB : kIs1024
|
||||||
|
state.counters["docs"] = Counter(double(state.iterations()), benchmark::Counter::kIsRate);
|
||||||
|
}
|
||||||
|
BENCHMARK(fast_minify_gsoc)->Repetitions(10)->ComputeStatistics("max", [](const std::vector<double>& v) -> double {
|
||||||
|
return *(std::max_element(std::begin(v), std::end(v)));
|
||||||
|
})->DisplayAggregatesOnly(true);
|
||||||
|
|
||||||
static void unicode_validate_twitter(State& state) {
|
static void unicode_validate_twitter(State& state) {
|
||||||
dom::parser parser;
|
dom::parser parser;
|
||||||
padded_string docdata;
|
padded_string docdata;
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ struct option_struct {
|
|||||||
verbose = true;
|
verbose = true;
|
||||||
break;
|
break;
|
||||||
case 'a': {
|
case 'a': {
|
||||||
auto impl = simdjson::available_implementations[optarg];
|
auto impl = simdjson::get_available_implementations()[optarg];
|
||||||
if(impl && impl->supported_by_runtime_system()) {
|
if(impl && impl->supported_by_runtime_system()) {
|
||||||
simdjson::active_implementation = impl;
|
simdjson::get_active_implementation() = impl;
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "implementation " << optarg << " not found or not supported " << std::endl;
|
std::cerr << "implementation " << optarg << " not found or not supported " << std::endl;
|
||||||
}
|
}
|
||||||
@@ -204,10 +204,13 @@ struct feature_benchmarker {
|
|||||||
}
|
}
|
||||||
// Rate of 1-7-structural misses per 8-structural flip
|
// Rate of 1-7-structural misses per 8-structural flip
|
||||||
double struct1_7_miss_rate(BenchmarkStage stage) const {
|
double struct1_7_miss_rate(BenchmarkStage stage) const {
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
if (!has_events()) { return 1; }
|
if (!has_events()) { return 1; }
|
||||||
return struct7_miss[stage].best.branch_misses() - struct7[stage].best.branch_misses() / double(struct7_miss.stats->blocks_with_1_structural_flipped);
|
return struct7_miss[stage].best.branch_misses() - struct7[stage].best.branch_misses() / double(struct7_miss.stats->blocks_with_1_structural_flipped);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra cost of an 8-15 structural block over a 1-7 structural block
|
// Extra cost of an 8-15 structural block over a 1-7 structural block
|
||||||
double struct8_15_cost(BenchmarkStage stage) const {
|
double struct8_15_cost(BenchmarkStage stage) const {
|
||||||
return cost_per_block(stage, struct15, struct15.stats->blocks_with_8_structurals, struct7);
|
return cost_per_block(stage, struct15, struct15.stats->blocks_with_8_structurals, struct7);
|
||||||
@@ -218,8 +221,12 @@ struct feature_benchmarker {
|
|||||||
}
|
}
|
||||||
// Rate of 8-15-structural misses per 8-structural flip
|
// Rate of 8-15-structural misses per 8-structural flip
|
||||||
double struct8_15_miss_rate(BenchmarkStage stage) const {
|
double struct8_15_miss_rate(BenchmarkStage stage) const {
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
if (!has_events()) { return 1; }
|
if (!has_events()) { return 1; }
|
||||||
return double(struct15_miss[stage].best.branch_misses() - struct15[stage].best.branch_misses()) / double(struct15_miss.stats->blocks_with_8_structurals_flipped);
|
return double(struct15_miss[stage].best.branch_misses() - struct15[stage].best.branch_misses()) / double(struct15_miss.stats->blocks_with_8_structurals_flipped);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra cost of a 16+-structural block over an 8-15 structural block (actual varies based on # of structurals!)
|
// Extra cost of a 16+-structural block over an 8-15 structural block (actual varies based on # of structurals!)
|
||||||
@@ -232,10 +239,15 @@ struct feature_benchmarker {
|
|||||||
}
|
}
|
||||||
// Rate of 16-structural misses per 16-structural flip
|
// Rate of 16-structural misses per 16-structural flip
|
||||||
double struct16_miss_rate(BenchmarkStage stage) const {
|
double struct16_miss_rate(BenchmarkStage stage) const {
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
if (!has_events()) { return 1; }
|
if (!has_events()) { return 1; }
|
||||||
return double(struct23_miss[stage].best.branch_misses() - struct23[stage].best.branch_misses()) / double(struct23_miss.stats->blocks_with_16_structurals_flipped);
|
return double(struct23_miss[stage].best.branch_misses() - struct23[stage].best.branch_misses()) / double(struct23_miss.stats->blocks_with_16_structurals_flipped);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extra cost of having UTF-8 in a block
|
// Extra cost of having UTF-8 in a block
|
||||||
double utf8_cost(BenchmarkStage stage) const {
|
double utf8_cost(BenchmarkStage stage) const {
|
||||||
return cost_per_block(stage, utf8, utf8.stats->blocks_with_utf8, struct7_full);
|
return cost_per_block(stage, utf8, utf8.stats->blocks_with_utf8, struct7_full);
|
||||||
@@ -246,10 +258,13 @@ struct feature_benchmarker {
|
|||||||
}
|
}
|
||||||
// Rate of UTF-8 misses per UTF-8 flip
|
// Rate of UTF-8 misses per UTF-8 flip
|
||||||
double utf8_miss_rate(BenchmarkStage stage) const {
|
double utf8_miss_rate(BenchmarkStage stage) const {
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
if (!has_events()) { return 1; }
|
if (!has_events()) { return 1; }
|
||||||
return double(utf8_miss[stage].best.branch_misses() - utf8[stage].best.branch_misses()) / double(utf8_miss.stats->blocks_with_utf8_flipped);
|
return double(utf8_miss[stage].best.branch_misses() - utf8[stage].best.branch_misses()) / double(utf8_miss.stats->blocks_with_utf8_flipped);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra cost of having escapes in a block
|
// Extra cost of having escapes in a block
|
||||||
double escape_cost(BenchmarkStage stage) const {
|
double escape_cost(BenchmarkStage stage) const {
|
||||||
return cost_per_block(stage, escape, escape.stats->blocks_with_escapes, struct7_full);
|
return cost_per_block(stage, escape, escape.stats->blocks_with_escapes, struct7_full);
|
||||||
@@ -260,10 +275,15 @@ struct feature_benchmarker {
|
|||||||
}
|
}
|
||||||
// Rate of escape misses per escape flip
|
// Rate of escape misses per escape flip
|
||||||
double escape_miss_rate(BenchmarkStage stage) const {
|
double escape_miss_rate(BenchmarkStage stage) const {
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
if (!has_events()) { return 1; }
|
if (!has_events()) { return 1; }
|
||||||
return double(escape_miss[stage].best.branch_misses() - escape[stage].best.branch_misses()) / double(escape_miss.stats->blocks_with_escapes_flipped);
|
return double(escape_miss[stage].best.branch_misses() - escape[stage].best.branch_misses()) / double(escape_miss.stats->blocks_with_escapes_flipped);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double calc_expected_feature_cost(BenchmarkStage stage, const benchmarker& file) const {
|
double calc_expected_feature_cost(BenchmarkStage stage, const benchmarker& file) const {
|
||||||
// Expected base ns/block (empty)
|
// Expected base ns/block (empty)
|
||||||
json_stats& stats = *file.stats;
|
json_stats& stats = *file.stats;
|
||||||
@@ -300,7 +320,6 @@ struct feature_benchmarker {
|
|||||||
double calc_expected(BenchmarkStage stage, const benchmarker& file) const {
|
double calc_expected(BenchmarkStage stage, const benchmarker& file) const {
|
||||||
return calc_expected_feature_cost(stage, file) + calc_expected_miss_cost(stage, file);
|
return calc_expected_feature_cost(stage, file) + calc_expected_miss_cost(stage, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(const option_struct& options) const {
|
void print(const option_struct& options) const {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Features in ns/block (64 bytes):\n");
|
printf("Features in ns/block (64 bytes):\n");
|
||||||
@@ -359,6 +378,22 @@ struct feature_benchmarker {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
void print_file_effectiveness(BenchmarkStage stage, const char* filename, const benchmarker& results, const feature_benchmarker& features) {
|
||||||
|
double actual = results[stage].best.elapsed_ns() / double(results.stats->blocks);
|
||||||
|
double calc = features.calc_expected(stage, results);
|
||||||
|
double calc_misses = features.calc_expected_misses(stage, results);
|
||||||
|
double calc_miss_cost = features.calc_expected_miss_cost(stage, results);
|
||||||
|
printf(" | %-8s ", benchmark_stage_name(stage));
|
||||||
|
printf("| %-15s ", filename);
|
||||||
|
printf("| %8.3g ", features.calc_expected_feature_cost(stage, results));
|
||||||
|
printf("| %8.3g ", calc_miss_cost);
|
||||||
|
printf("| %8.3g ", calc);
|
||||||
|
printf("| %8.3g ", actual);
|
||||||
|
printf("| %+8.3g ", actual - calc);
|
||||||
|
printf("| %13llu ", (long long unsigned)(calc_misses));
|
||||||
|
}
|
||||||
|
#else
|
||||||
void print_file_effectiveness(BenchmarkStage stage, const char* filename, const benchmarker& results, const feature_benchmarker& features) {
|
void print_file_effectiveness(BenchmarkStage stage, const char* filename, const benchmarker& results, const feature_benchmarker& features) {
|
||||||
double actual = results[stage].best.elapsed_ns() / double(results.stats->blocks);
|
double actual = results[stage].best.elapsed_ns() / double(results.stats->blocks);
|
||||||
double calc = features.calc_expected(stage, results);
|
double calc = features.calc_expected(stage, results);
|
||||||
@@ -382,6 +417,7 @@ void print_file_effectiveness(BenchmarkStage stage, const char* filename, const
|
|||||||
}
|
}
|
||||||
printf("|\n");
|
printf("|\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// Read options
|
// Read options
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define __BENCHMARKER_H
|
#define __BENCHMARKER_H
|
||||||
|
|
||||||
#include "event_counter.h"
|
#include "event_counter.h"
|
||||||
#include "simdjson.h" // For SIMDJSON_DISABLE_DEPRECATED_WARNINGS
|
#include "simdjson.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
@@ -331,7 +331,7 @@ struct benchmarker {
|
|||||||
|
|
||||||
// Stage 1 (find structurals)
|
// Stage 1 (find structurals)
|
||||||
collector.start();
|
collector.start();
|
||||||
error = parser.implementation->stage1(reinterpret_cast<const uint8_t *>(json.data()), json.size(), false);
|
error = parser.implementation->stage1(reinterpret_cast<const uint8_t *>(json.data()), json.size(), stage1_mode::regular);
|
||||||
event_count stage1_count = collector.end();
|
event_count stage1_count = collector.end();
|
||||||
stage1 << stage1_count;
|
stage1 << stage1_count;
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -423,7 +423,7 @@ struct benchmarker {
|
|||||||
stage.instructions() / static_cast<double>(stats->structurals),
|
stage.instructions() / static_cast<double>(stats->structurals),
|
||||||
stage.instructions() / static_cast<double>(stage.cycles())
|
stage.instructions() / static_cast<double>(stage.cycles())
|
||||||
);
|
);
|
||||||
|
#if !SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
// NOTE: removed cycles/miss because it is a somewhat misleading stat
|
// NOTE: removed cycles/miss because it is a somewhat misleading stat
|
||||||
printf("%s%-13s: %7.0f branch misses (%6.2f%%) - %.0f cache misses (%6.2f%%) - %.2f cache references\n",
|
printf("%s%-13s: %7.0f branch misses (%6.2f%%) - %.0f cache misses (%6.2f%%) - %.2f cache references\n",
|
||||||
prefix,
|
prefix,
|
||||||
@@ -434,6 +434,7 @@ struct benchmarker {
|
|||||||
percent(stage.cache_misses(), all_stages_without_allocation.cache_misses()),
|
percent(stage.cache_misses(), all_stages_without_allocation.cache_misses()),
|
||||||
stage.cache_references()
|
stage.cache_references()
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
|
|
||||||
|
#include "distinct_user_id.h"
|
||||||
|
|
||||||
|
namespace distinct_user_id {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
struct nlohmann_json_sax {
|
||||||
|
struct Handler : json::json_sax_t
|
||||||
|
{
|
||||||
|
std::vector<uint64_t>& result;
|
||||||
|
bool user = false;
|
||||||
|
bool user_id = false;
|
||||||
|
Handler(std::vector<uint64_t> &r) : result(r) { }
|
||||||
|
|
||||||
|
bool key(string_t& val) override {
|
||||||
|
// Assume that valid user/id pairs appear only once in main array of user objects
|
||||||
|
if (user) { // If already found user object, find id key
|
||||||
|
if (val.compare("id") == 0) { user_id = true; }
|
||||||
|
}
|
||||||
|
else if (val.compare("user") == 0) { user = true; } // Otherwise, find user object
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_unsigned(number_unsigned_t val) override {
|
||||||
|
if (user_id) {
|
||||||
|
result.emplace_back(val);
|
||||||
|
user = false;
|
||||||
|
user_id = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool null() override { return true; }
|
||||||
|
bool boolean(bool val) override { return true; }
|
||||||
|
bool number_float(number_float_t val, const string_t& s) override { return true; }
|
||||||
|
bool number_integer(number_integer_t val) override { return true; }
|
||||||
|
bool string(string_t& val) override { return true; }
|
||||||
|
bool start_object(std::size_t elements) override { return true; }
|
||||||
|
bool end_object() override { return true; }
|
||||||
|
bool start_array(std::size_t elements) override { return true; }
|
||||||
|
bool end_array() override { return true; }
|
||||||
|
bool binary(json::binary_t& val) override { return true; }
|
||||||
|
bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override { return false; }
|
||||||
|
}; // Handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) {
|
||||||
|
Handler handler(result);
|
||||||
|
json::sax_parse(json.data(), &handler);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // nlohmann_json_sax
|
||||||
|
BENCHMARK_TEMPLATE(distinct_user_id, nlohmann_json_sax)->UseManualTime();
|
||||||
|
} // namespace distinct_user_id
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|
||||||
|
#include "distinct_user_id.h"
|
||||||
|
#include <string.h>
|
||||||
|
namespace distinct_user_id {
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
|
||||||
|
struct rapidjson_sax {
|
||||||
|
struct Handler {
|
||||||
|
std::vector<uint64_t>& result;
|
||||||
|
bool user = false;
|
||||||
|
bool user_id = false;
|
||||||
|
Handler(std::vector<uint64_t> &r) : result(r) { }
|
||||||
|
|
||||||
|
bool Key(const char* key, SizeType length, bool copy) {
|
||||||
|
// Assume that valid user/id pairs appear only once in main array of user objects
|
||||||
|
if (user) { // If already found user object, find id key
|
||||||
|
if ((length == 2) && memcmp(key,"id",2) == 0) { user_id = true; }
|
||||||
|
}
|
||||||
|
else if ((length == 4) && memcmp(key,"user",4) == 0) { user = true; } // Otherwise, find user object
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Uint(unsigned i) { // id values are treated as Uint (not Uint64) by the reader
|
||||||
|
if (user_id) { // Getting id if previous key was "id" for a user
|
||||||
|
result.emplace_back(i);
|
||||||
|
user_id = false;
|
||||||
|
user = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool Null() { return true; }
|
||||||
|
bool Bool(bool b) { return true; }
|
||||||
|
bool Double(double d) { return true; }
|
||||||
|
bool Int(int i) { return true; }
|
||||||
|
bool Int64(int64_t i) { return true; }
|
||||||
|
bool Uint64(uint64_t i) { return true; }
|
||||||
|
bool RawNumber(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool String(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool StartObject() { return true; }
|
||||||
|
bool EndObject(SizeType memberCount) { return true; }
|
||||||
|
bool StartArray() { return true; }
|
||||||
|
bool EndArray(SizeType elementCount) { return true; }
|
||||||
|
}; // handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) {
|
||||||
|
Reader reader;
|
||||||
|
Handler handler(result);
|
||||||
|
InsituStringStream ss(json.data());
|
||||||
|
reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag | kParseFullPrecisionFlag>(ss,handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // rapid_jason_sax
|
||||||
|
BENCHMARK_TEMPLATE(distinct_user_id, rapidjson_sax)->UseManualTime();
|
||||||
|
} // namespace distinct_user_id
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
#include "distinct_user_id.h"
|
||||||
|
|
||||||
|
namespace distinct_user_id {
|
||||||
|
|
||||||
|
using namespace simdjson;
|
||||||
|
|
||||||
|
struct simdjson_dom_json_pointer {
|
||||||
|
dom::parser parser{};
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) {
|
||||||
|
// Walk the document, parsing as we go
|
||||||
|
auto doc = parser.parse(json);
|
||||||
|
for (dom::object tweet : doc["statuses"]) {
|
||||||
|
// We believe that all statuses have a matching
|
||||||
|
// user, and we are willing to throw when they do not.
|
||||||
|
result.push_back(tweet.at_pointer("/user/id"));
|
||||||
|
// Not all tweets have a "retweeted_status", but when they do
|
||||||
|
// we want to go and find the user within.
|
||||||
|
auto retweet_id = tweet.at_pointer("/retweeted_status/user/id");
|
||||||
|
if (retweet_id.error() != NO_SUCH_FIELD) {
|
||||||
|
result.push_back(retweet_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK_TEMPLATE(distinct_user_id, simdjson_dom_json_pointer)->UseManualTime();
|
||||||
|
|
||||||
|
} // namespace distinct_user_id
|
||||||
|
|
||||||
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
#include "distinct_user_id.h"
|
||||||
|
|
||||||
|
namespace distinct_user_id {
|
||||||
|
|
||||||
|
using namespace simdjson;
|
||||||
|
|
||||||
|
struct simdjson_ondemand_json_pointer {
|
||||||
|
ondemand::parser parser{};
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<uint64_t> &result) {
|
||||||
|
// Walk the document, parsing as we go
|
||||||
|
auto doc = parser.iterate(json);
|
||||||
|
for (ondemand::object tweet : doc.find_field("statuses")) {
|
||||||
|
// We believe that all statuses have a matching
|
||||||
|
// user, and we are willing to throw when they do not.
|
||||||
|
result.push_back(tweet.at_pointer("/user/id"));
|
||||||
|
// Not all tweets have a "retweeted_status", but when they do
|
||||||
|
// we want to go and find the user within.
|
||||||
|
auto retweet_id = tweet.at_pointer("/retweeted_status/user/id");
|
||||||
|
if (retweet_id.error() != NO_SUCH_FIELD) {
|
||||||
|
result.push_back(retweet_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK_TEMPLATE(distinct_user_id, simdjson_ondemand_json_pointer)->UseManualTime();
|
||||||
|
|
||||||
|
} // namespace distinct_user_id
|
||||||
|
|
||||||
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
include_directories( .. ../linux )
|
||||||
|
link_libraries(simdjson-windows-headers test-data)
|
||||||
|
link_libraries(simdjson)
|
||||||
|
|
||||||
|
add_executable(perfdiff perfdiff.cpp)
|
||||||
|
add_executable(parse parse.cpp)
|
||||||
|
add_executable(parse_stream parse_stream.cpp)
|
||||||
|
add_executable(statisticalmodel statisticalmodel.cpp)
|
||||||
|
|
||||||
|
add_executable(parse_noutf8validation parse.cpp)
|
||||||
|
target_compile_definitions(parse_noutf8validation PRIVATE SIMDJSON_SKIPUTF8VALIDATION)
|
||||||
|
add_executable(parse_nonumberparsing parse.cpp)
|
||||||
|
target_compile_definitions(parse_nonumberparsing PRIVATE SIMDJSON_SKIPNUMBERPARSING)
|
||||||
|
add_executable(parse_nostringparsing parse.cpp)
|
||||||
|
target_compile_definitions(parse_nostringparsing PRIVATE SIMDJSON_SKIPSTRINGPARSING)
|
||||||
|
include(checkperf.cmake)
|
||||||
@@ -5,9 +5,12 @@
|
|||||||
# checkperf-repo: initialize and sync reference repository (first time only)
|
# checkperf-repo: initialize and sync reference repository (first time only)
|
||||||
# TEST checkperf: runs the actual checkperf test
|
# TEST checkperf: runs the actual checkperf test
|
||||||
|
|
||||||
|
option(SIMDJSON_ENABLE_DOM_CHECKPERF "Enable DOM performance comparison with main branch" OFF)
|
||||||
|
|
||||||
|
|
||||||
# Clone the repository if it's not there
|
# Clone the repository if it's not there
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
if (Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4") AND (NOT CMAKE_GENERATOR MATCHES Ninja) AND (NOT MSVC) ) # We use "-C" which requires a recent git
|
if (SIMDJSON_ENABLE_DOM_CHECKPERF AND Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4") AND (NOT CMAKE_GENERATOR MATCHES Ninja) AND (NOT MSVC) ) # We use "-C" which requires a recent git
|
||||||
message(STATUS "Git is available and it is recent. We are enabling checkperf targets.")
|
message(STATUS "Git is available and it is recent. We are enabling checkperf targets.")
|
||||||
# sync_git_repository(myrepo ...) creates two targets:
|
# sync_git_repository(myrepo ...) creates two targets:
|
||||||
# myrepo - if the repo does not exist, creates and syncs it against the origin branch
|
# myrepo - if the repo does not exist, creates and syncs it against the origin branch
|
||||||
@@ -61,7 +64,13 @@ if (Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4") AND (NOT CMAKE_G
|
|||||||
OUTPUT ${SIMDJSON_CHECKPERF_DIR}/build/cmake_install.cmake # We make many things but this seems the most cross-platform one we can depend on
|
OUTPUT ${SIMDJSON_CHECKPERF_DIR}/build/cmake_install.cmake # We make many things but this seems the most cross-platform one we can depend on
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_COMMAND} -E env CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER}
|
${CMAKE_COMMAND} -E env CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER}
|
||||||
${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_COMPETITION=OFF -G ${CMAKE_GENERATOR} ..
|
${CMAKE_COMMAND}
|
||||||
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
-DSIMDJSON_GOOGLE_BENCHMARKS=OFF
|
||||||
|
-DSIMDJSON_COMPETITION=OFF
|
||||||
|
-DSIMDJSON_DEVELOPER_MODE=YES
|
||||||
|
-G ${CMAKE_GENERATOR}
|
||||||
|
..
|
||||||
WORKING_DIRECTORY ${SIMDJSON_CHECKPERF_DIR}/build
|
WORKING_DIRECTORY ${SIMDJSON_CHECKPERF_DIR}/build
|
||||||
DEPENDS ${SIMDJSON_CHECKPERF_DIR}/build/CMakeCache.txt
|
DEPENDS ${SIMDJSON_CHECKPERF_DIR}/build/CMakeCache.txt
|
||||||
)
|
)
|
||||||
@@ -70,7 +79,7 @@ if (Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4") AND (NOT CMAKE_G
|
|||||||
if (CMAKE_CONFIGURATION_TYPES)
|
if (CMAKE_CONFIGURATION_TYPES)
|
||||||
set(CHECKPERF_PARSE ${SIMDJSON_CHECKPERF_DIR}/build/benchmark/$<CONFIGURATION>/parse)
|
set(CHECKPERF_PARSE ${SIMDJSON_CHECKPERF_DIR}/build/benchmark/$<CONFIGURATION>/parse)
|
||||||
else()
|
else()
|
||||||
set(CHECKPERF_PARSE ${SIMDJSON_CHECKPERF_DIR}/build/benchmark/parse)
|
set(CHECKPERF_PARSE ${SIMDJSON_CHECKPERF_DIR}/build/benchmark/dom/parse)
|
||||||
endif()
|
endif()
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
checkperf-parse ALL # TODO is ALL necessary?
|
checkperf-parse ALL # TODO is ALL necessary?
|
||||||
@@ -92,6 +101,8 @@ if (Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4") AND (NOT CMAKE_G
|
|||||||
set_property(TEST checkperf APPEND PROPERTY LABELS per_implementation explicitonly)
|
set_property(TEST checkperf APPEND PROPERTY LABELS per_implementation explicitonly)
|
||||||
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE})
|
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE})
|
||||||
set_property(TEST checkperf PROPERTY RUN_SERIAL TRUE)
|
set_property(TEST checkperf PROPERTY RUN_SERIAL TRUE)
|
||||||
|
add_dependencies(per_implementation_tests checkperf)
|
||||||
|
add_dependencies(explicitonly_tests checkperf)
|
||||||
else()
|
else()
|
||||||
if (CMAKE_GENERATOR MATCHES Ninja)
|
if (CMAKE_GENERATOR MATCHES Ninja)
|
||||||
message(STATUS "We disable the checkperf targets under Ninja.")
|
message(STATUS "We disable the checkperf targets under Ninja.")
|
||||||
@@ -66,7 +66,7 @@ void print_usage(ostream& out) {
|
|||||||
out << "-H - Make the buffers hot (reduce page allocation and related OS tasks during parsing) [default]" << endl;
|
out << "-H - Make the buffers hot (reduce page allocation and related OS tasks during parsing) [default]" << endl;
|
||||||
out << "-a IMPL - Use the given parser implementation. By default, detects the most advanced" << endl;
|
out << "-a IMPL - Use the given parser implementation. By default, detects the most advanced" << endl;
|
||||||
out << " implementation supported on the host machine." << endl;
|
out << " implementation supported on the host machine." << endl;
|
||||||
for (auto impl : simdjson::available_implementations) {
|
for (auto impl : simdjson::get_available_implementations()) {
|
||||||
if(impl->supported_by_runtime_system()) {
|
if(impl->supported_by_runtime_system()) {
|
||||||
out << "-a " << std::left << std::setw(9) << impl->name() << " - Use the " << impl->description() << " parser implementation." << endl;
|
out << "-a " << std::left << std::setw(9) << impl->name() << " - Use the " << impl->description() << " parser implementation." << endl;
|
||||||
}
|
}
|
||||||
@@ -116,10 +116,10 @@ struct option_struct {
|
|||||||
verbose = true;
|
verbose = true;
|
||||||
break;
|
break;
|
||||||
case 'a': {
|
case 'a': {
|
||||||
const implementation *impl = simdjson::available_implementations[optarg];
|
const implementation *impl = simdjson::get_available_implementations()[optarg];
|
||||||
if ((!impl) || (!impl->supported_by_runtime_system())) {
|
if ((!impl) || (!impl->supported_by_runtime_system())) {
|
||||||
std::string exit_message = string("Unsupported option value -a ") + optarg + ": expected -a with one of ";
|
std::string exit_message = string("Unsupported option value -a ") + optarg + ": expected -a with one of ";
|
||||||
for (auto imple : simdjson::available_implementations) {
|
for (auto imple : simdjson::get_available_implementations()) {
|
||||||
if(imple->supported_by_runtime_system()) {
|
if(imple->supported_by_runtime_system()) {
|
||||||
exit_message += imple->name();
|
exit_message += imple->name();
|
||||||
exit_message += " ";
|
exit_message += " ";
|
||||||
@@ -127,7 +127,7 @@ struct option_struct {
|
|||||||
}
|
}
|
||||||
exit_usage(exit_message);
|
exit_usage(exit_message);
|
||||||
}
|
}
|
||||||
simdjson::active_implementation = impl;
|
simdjson::get_active_implementation() = impl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'C':
|
case 'C':
|
||||||
@@ -175,7 +175,7 @@ int main(int argc, char *argv[]) {
|
|||||||
option_struct options(argc, argv);
|
option_struct options(argc, argv);
|
||||||
if (options.verbose) {
|
if (options.verbose) {
|
||||||
verbose_stream = &cout;
|
verbose_stream = &cout;
|
||||||
verbose() << "Implementation: " << simdjson::active_implementation->name() << endl;
|
verbose() << "Implementation: " << simdjson::get_active_implementation()->name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start collecting events. We put this early so if it prints an error message, it's the
|
// Start collecting events. We put this early so if it prints an error message, it's the
|
||||||
@@ -50,9 +50,9 @@ simdjson_really_inline void simdjson_process_atom(stat_t &s,
|
|||||||
} else if(element.is<double>()) {
|
} else if(element.is<double>()) {
|
||||||
s.float_count++;
|
s.float_count++;
|
||||||
} else if (element.is<bool>()) {
|
} else if (element.is<bool>()) {
|
||||||
simdjson::error_code err;
|
|
||||||
bool v;
|
bool v;
|
||||||
err = element.get(v);
|
simdjson::error_code error;
|
||||||
|
if ((error = element.get(v))) { std::cerr << error << std::endl; abort(); }
|
||||||
if (v) {
|
if (v) {
|
||||||
s.true_count++;
|
s.true_count++;
|
||||||
} else {
|
} else {
|
||||||
@@ -183,7 +183,7 @@ int main(int argc, char *argv[]) {
|
|||||||
for (uint32_t i = 0; i < iterations; i++) {
|
for (uint32_t i = 0; i < iterations; i++) {
|
||||||
unified.start();
|
unified.start();
|
||||||
// The default template is simdjson::architecture::NATIVE.
|
// The default template is simdjson::architecture::NATIVE.
|
||||||
bool isok = (parser.implementation->stage1((const uint8_t *)p.data(), p.size(), false) == simdjson::SUCCESS);
|
bool isok = (parser.implementation->stage1((const uint8_t *)p.data(), p.size(), simdjson::stage1_mode::regular) == simdjson::SUCCESS);
|
||||||
unified.end(results);
|
unified.end(results);
|
||||||
|
|
||||||
cy1 += results[0];
|
cy1 += results[0];
|
||||||
@@ -1,6 +1,15 @@
|
|||||||
#ifndef __EVENT_COUNTER_H
|
#ifndef __EVENT_COUNTER_H
|
||||||
#define __EVENT_COUNTER_H
|
#define __EVENT_COUNTER_H
|
||||||
|
|
||||||
|
#ifndef SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
#ifdef __aarch64__
|
||||||
|
// on ARM, we use just cycles and instructions
|
||||||
|
#define SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS 1
|
||||||
|
#else
|
||||||
|
// elsewhere, we try to use four counters.
|
||||||
|
#define SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
@@ -46,6 +55,12 @@ struct event_count {
|
|||||||
event_count(const event_count& other): elapsed(other.elapsed), event_counts(other.event_counts) { }
|
event_count(const event_count& other): elapsed(other.elapsed), event_counts(other.event_counts) { }
|
||||||
|
|
||||||
// The types of counters (so we can read the getter more easily)
|
// The types of counters (so we can read the getter more easily)
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
enum event_counter_types {
|
||||||
|
CPU_CYCLES,
|
||||||
|
INSTRUCTIONS
|
||||||
|
};
|
||||||
|
#else
|
||||||
enum event_counter_types {
|
enum event_counter_types {
|
||||||
CPU_CYCLES,
|
CPU_CYCLES,
|
||||||
INSTRUCTIONS,
|
INSTRUCTIONS,
|
||||||
@@ -53,15 +68,16 @@ struct event_count {
|
|||||||
CACHE_REFERENCES,
|
CACHE_REFERENCES,
|
||||||
CACHE_MISSES
|
CACHE_MISSES
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
double elapsed_sec() const { return duration<double>(elapsed).count(); }
|
double elapsed_sec() const { return duration<double>(elapsed).count(); }
|
||||||
double elapsed_ns() const { return duration<double, std::nano>(elapsed).count(); }
|
double elapsed_ns() const { return duration<double, std::nano>(elapsed).count(); }
|
||||||
double cycles() const { return static_cast<double>(event_counts[CPU_CYCLES]); }
|
double cycles() const { return static_cast<double>(event_counts[CPU_CYCLES]); }
|
||||||
double instructions() const { return static_cast<double>(event_counts[INSTRUCTIONS]); }
|
double instructions() const { return static_cast<double>(event_counts[INSTRUCTIONS]); }
|
||||||
|
#if !SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
double branch_misses() const { return static_cast<double>(event_counts[BRANCH_MISSES]); }
|
double branch_misses() const { return static_cast<double>(event_counts[BRANCH_MISSES]); }
|
||||||
double cache_references() const { return static_cast<double>(event_counts[CACHE_REFERENCES]); }
|
double cache_references() const { return static_cast<double>(event_counts[CACHE_REFERENCES]); }
|
||||||
double cache_misses() const { return static_cast<double>(event_counts[CACHE_MISSES]); }
|
double cache_misses() const { return static_cast<double>(event_counts[CACHE_MISSES]); }
|
||||||
|
#endif
|
||||||
event_count& operator=(const event_count& other) {
|
event_count& operator=(const event_count& other) {
|
||||||
this->elapsed = other.elapsed;
|
this->elapsed = other.elapsed;
|
||||||
this->event_counts = other.event_counts;
|
this->event_counts = other.event_counts;
|
||||||
@@ -105,9 +121,11 @@ struct event_aggregate {
|
|||||||
double elapsed_ns() const { return total.elapsed_ns() / iterations; }
|
double elapsed_ns() const { return total.elapsed_ns() / iterations; }
|
||||||
double cycles() const { return total.cycles() / iterations; }
|
double cycles() const { return total.cycles() / iterations; }
|
||||||
double instructions() const { return total.instructions() / iterations; }
|
double instructions() const { return total.instructions() / iterations; }
|
||||||
|
#if !SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
double branch_misses() const { return total.branch_misses() / iterations; }
|
double branch_misses() const { return total.branch_misses() / iterations; }
|
||||||
double cache_references() const { return total.cache_references() / iterations; }
|
double cache_references() const { return total.cache_references() / iterations; }
|
||||||
double cache_misses() const { return total.cache_misses() / iterations; }
|
double cache_misses() const { return total.cache_misses() / iterations; }
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct event_collector {
|
struct event_collector {
|
||||||
@@ -117,11 +135,16 @@ struct event_collector {
|
|||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
LinuxEvents<PERF_TYPE_HARDWARE> linux_events;
|
LinuxEvents<PERF_TYPE_HARDWARE> linux_events;
|
||||||
event_collector(bool quiet = false) : linux_events(vector<int>{
|
event_collector(bool quiet = false) : linux_events(vector<int>{
|
||||||
|
#if SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
|
PERF_COUNT_HW_CPU_CYCLES,
|
||||||
|
PERF_COUNT_HW_INSTRUCTIONS,
|
||||||
|
#else
|
||||||
PERF_COUNT_HW_CPU_CYCLES,
|
PERF_COUNT_HW_CPU_CYCLES,
|
||||||
PERF_COUNT_HW_INSTRUCTIONS,
|
PERF_COUNT_HW_INSTRUCTIONS,
|
||||||
PERF_COUNT_HW_BRANCH_MISSES,
|
PERF_COUNT_HW_BRANCH_MISSES,
|
||||||
PERF_COUNT_HW_CACHE_REFERENCES,
|
PERF_COUNT_HW_CACHE_REFERENCES,
|
||||||
PERF_COUNT_HW_CACHE_MISSES
|
PERF_COUNT_HW_CACHE_MISSES
|
||||||
|
#endif
|
||||||
}, quiet) {}
|
}, quiet) {}
|
||||||
bool has_events() {
|
bool has_events() {
|
||||||
return linux_events.is_working();
|
return linux_events.is_working();
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
|
|
||||||
|
#include "find_tweet.h"
|
||||||
|
|
||||||
|
namespace find_tweet {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
struct nlohmann_json_sax {
|
||||||
|
using StringType=std::string;
|
||||||
|
|
||||||
|
struct Handler : json::json_sax_t
|
||||||
|
{
|
||||||
|
bool text_key = false;
|
||||||
|
bool id_key = false;
|
||||||
|
bool found_id = false;
|
||||||
|
uint64_t find_id;
|
||||||
|
std::string &result;
|
||||||
|
|
||||||
|
Handler(std::string &r,uint64_t id): result(r), find_id(id) { }
|
||||||
|
|
||||||
|
// We assume id is found before text
|
||||||
|
bool key(string_t& val) override {
|
||||||
|
if (found_id) { // If have found id, find text key
|
||||||
|
if (val.compare("text") == 0) { text_key = true; }
|
||||||
|
}
|
||||||
|
else if (val.compare("id") == 0) { id_key = true; } // Otherwise, find id key
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_unsigned(number_unsigned_t val) override {
|
||||||
|
if (id_key && (val == find_id)) { // If id key, check if id value matches find_id
|
||||||
|
found_id = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool string(string_t& val) override {
|
||||||
|
if (text_key) {
|
||||||
|
result = val;
|
||||||
|
return false; // End parsing
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool null() override { return true; }
|
||||||
|
bool boolean(bool val) override { return true; }
|
||||||
|
bool number_float(number_float_t val, const string_t& s) override { return true; }
|
||||||
|
bool number_integer(number_integer_t val) override { return true; }
|
||||||
|
bool start_object(std::size_t elements) override { return true; }
|
||||||
|
bool end_object() override { return true; }
|
||||||
|
bool start_array(std::size_t elements) override { return true; }
|
||||||
|
bool end_array() override { return true; }
|
||||||
|
bool binary(json::binary_t& val) override { return true; }
|
||||||
|
bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override { return false; }
|
||||||
|
}; // Handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, uint64_t find_id, std::string &result) {
|
||||||
|
Handler handler(result,find_id);
|
||||||
|
json::sax_parse(json.data(), &handler);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // nlohmann_json_sax
|
||||||
|
BENCHMARK_TEMPLATE(find_tweet, nlohmann_json_sax)->UseManualTime();
|
||||||
|
} // namespace find_tweet
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
@@ -47,6 +47,6 @@ struct rapidjson_insitu : rapidjson_base {
|
|||||||
};
|
};
|
||||||
BENCHMARK_TEMPLATE(find_tweet, rapidjson_insitu)->UseManualTime();
|
BENCHMARK_TEMPLATE(find_tweet, rapidjson_insitu)->UseManualTime();
|
||||||
|
|
||||||
} // namespace partial_tweets
|
} // namespace find_tweet
|
||||||
|
|
||||||
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|
||||||
|
#include "find_tweet.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace find_tweet {
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
|
||||||
|
struct rapidjson_sax {
|
||||||
|
using StringType=std::string_view;
|
||||||
|
|
||||||
|
struct Handler {
|
||||||
|
bool text_key = false;
|
||||||
|
bool id_key = false;
|
||||||
|
bool found_id = false;
|
||||||
|
uint64_t find_id;
|
||||||
|
std::string_view &result;
|
||||||
|
|
||||||
|
Handler(std::string_view &r,uint64_t id): result(r), find_id(id) { }
|
||||||
|
|
||||||
|
// We assume id is found before text
|
||||||
|
bool Key(const char* key, SizeType length, bool copy) {
|
||||||
|
if (found_id) { // If have found id, find text key
|
||||||
|
if ((length == 4) && (memcmp(key,"text",4) == 0)) { text_key = true; }
|
||||||
|
}
|
||||||
|
else if ((length == 2) && (memcmp(key,"id",2) == 0)) { id_key = true; } // Otherwise, find id key
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Uint64(uint64_t i) {
|
||||||
|
if (id_key && (i == find_id)) { // If id key, check if id value matches find_id
|
||||||
|
found_id = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool String(const char* str, SizeType length, bool copy) {
|
||||||
|
if (text_key) {
|
||||||
|
result = {str,length};
|
||||||
|
return false; // End parsing
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool Null() { return true; }
|
||||||
|
bool Bool(bool b) { return true; }
|
||||||
|
bool Double(double d) { return true; }
|
||||||
|
bool Int(int i) { return true; }
|
||||||
|
bool Int64(int64_t i) { return true; }
|
||||||
|
bool Uint(unsigned i) { return true; }
|
||||||
|
bool RawNumber(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool StartObject() { return true; }
|
||||||
|
bool EndObject(SizeType memberCount) { return true; }
|
||||||
|
bool StartArray() { return true; }
|
||||||
|
bool EndArray(SizeType elementCount) { return true; }
|
||||||
|
}; // handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, uint64_t find_id, std::string_view &result) {
|
||||||
|
Reader reader;
|
||||||
|
Handler handler(result,find_id);
|
||||||
|
InsituStringStream ss(json.data());
|
||||||
|
reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag | kParseFullPrecisionFlag>(ss,handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // rapidjson_sax
|
||||||
|
BENCHMARK_TEMPLATE(find_tweet, rapidjson_sax)->UseManualTime();
|
||||||
|
} // namespace find_tweet
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
@@ -4,5 +4,6 @@ namespace json_benchmark {
|
|||||||
|
|
||||||
static constexpr const char *TWITTER_JSON = SIMDJSON_BENCHMARK_DATA_DIR "twitter.json";
|
static constexpr const char *TWITTER_JSON = SIMDJSON_BENCHMARK_DATA_DIR "twitter.json";
|
||||||
static constexpr const char *NUMBERS_JSON = SIMDJSON_BENCHMARK_DATA_DIR "numbers.json";
|
static constexpr const char *NUMBERS_JSON = SIMDJSON_BENCHMARK_DATA_DIR "numbers.json";
|
||||||
|
static constexpr const char *AMAZON_CELLPHONES_NDJSON = SIMDJSON_BENCHMARK_DATA_DIR "amazon_cellphones.ndjson";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
@@ -52,6 +53,56 @@ struct result_differ<std::vector<T>, std::vector<U>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T, typename U, typename StringType>
|
||||||
|
struct result_differ<std::map<StringType,T>, std::map<StringType,U>> {
|
||||||
|
static bool diff(benchmark::State &state, const std::map<StringType,T> &result, const std::map<StringType,U> &reference, diff_flags flags) {
|
||||||
|
auto result_iter = result.begin();
|
||||||
|
auto reference_iter = reference.begin();
|
||||||
|
while (result_iter != result.end() && reference_iter != reference.end()) {
|
||||||
|
if (!diff_results(state, *result_iter, *reference_iter, flags)) { return false; }
|
||||||
|
result_iter++;
|
||||||
|
reference_iter++;
|
||||||
|
}
|
||||||
|
if (result_iter != result.end()) {
|
||||||
|
std::stringstream str;
|
||||||
|
str << "extra results (got " << result.size() << ", expected " << reference.size() << "): first extra element: " << *result_iter;
|
||||||
|
state.SkipWithError(str.str().data());
|
||||||
|
return false;
|
||||||
|
} else if (reference_iter != reference.end()) {
|
||||||
|
std::stringstream str;
|
||||||
|
str << "missing results (got " << result.size() << ", expected " << reference.size() << "): first missing element: " << *reference_iter;
|
||||||
|
state.SkipWithError(str.str().data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T, typename U>
|
||||||
|
struct result_differ<std::map<std::string_view,T>, std::vector<std::string_view,U>> {
|
||||||
|
static bool diff(benchmark::State &state, const std::map<std::string_view,T> &result, const std::map<std::string_view,U> &reference, diff_flags flags) {
|
||||||
|
auto result_iter = result.begin();
|
||||||
|
auto reference_iter = reference.begin();
|
||||||
|
while (result_iter != result.end() && reference_iter != reference.end()) {
|
||||||
|
if (!diff_results(state, *result_iter, *reference_iter, flags)) { return false; }
|
||||||
|
result_iter++;
|
||||||
|
reference_iter++;
|
||||||
|
}
|
||||||
|
if (result_iter != result.end()) {
|
||||||
|
std::stringstream str;
|
||||||
|
str << "extra results (got " << result.size() << ", expected " << reference.size() << "): first extra element: " << *result_iter;
|
||||||
|
state.SkipWithError(str.str().data());
|
||||||
|
return false;
|
||||||
|
} else if (reference_iter != reference.end()) {
|
||||||
|
std::stringstream str;
|
||||||
|
str << "missing results (got " << result.size() << ", expected " << reference.size() << "): first missing element: " << *reference_iter;
|
||||||
|
state.SkipWithError(str.str().data());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct result_differ<double, double> {
|
struct result_differ<double, double> {
|
||||||
static bool diff(benchmark::State &state, const double &result, const double &reference, diff_flags flags) {
|
static bool diff(benchmark::State &state, const double &result, const double &reference, diff_flags flags) {
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ void maybe_display_implementation() {
|
|||||||
static bool displayed_implementation = false;
|
static bool displayed_implementation = false;
|
||||||
if(!displayed_implementation) {
|
if(!displayed_implementation) {
|
||||||
displayed_implementation = true;
|
displayed_implementation = true;
|
||||||
std::cout << "simdjson::dom implementation: " << simdjson::active_implementation->name() << std::endl;
|
std::cout << "simdjson::dom implementation: " << simdjson::get_active_implementation()->name() << std::endl;
|
||||||
std::cout << "simdjson::ondemand implementation (stage 1): " << simdjson::active_implementation->name() << std::endl;
|
std::cout << "simdjson::ondemand implementation (stage 1): " << simdjson::get_active_implementation()->name() << std::endl;
|
||||||
std::cout << "simdjson::ondemand implementation (stage 2): " << simdjson::builtin_implementation()->name() << std::endl;
|
std::cout << "simdjson::ondemand implementation (stage 2): " << simdjson::builtin_implementation()->name() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,10 +58,11 @@ template<typename B, typename R> static void run_json_benchmark(benchmark::State
|
|||||||
if (collector.has_events()) {
|
if (collector.has_events()) {
|
||||||
state.counters["instructions"] = events.instructions();
|
state.counters["instructions"] = events.instructions();
|
||||||
state.counters["cycles"] = events.cycles();
|
state.counters["cycles"] = events.cycles();
|
||||||
|
#if !SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
state.counters["branch_miss"] = events.branch_misses();
|
state.counters["branch_miss"] = events.branch_misses();
|
||||||
state.counters["cache_miss"] = events.cache_misses();
|
state.counters["cache_miss"] = events.cache_misses();
|
||||||
state.counters["cache_ref"] = events.cache_references();
|
state.counters["cache_ref"] = events.cache_references();
|
||||||
|
#endif
|
||||||
state.counters["instructions_per_byte"] = events.instructions() / double(bench.bytes_per_iteration());
|
state.counters["instructions_per_byte"] = events.instructions() / double(bench.bytes_per_iteration());
|
||||||
state.counters["instructions_per_cycle"] = events.instructions() / events.cycles();
|
state.counters["instructions_per_cycle"] = events.instructions() / events.cycles();
|
||||||
state.counters["cycles_per_byte"] = events.cycles() / double(bench.bytes_per_iteration());
|
state.counters["cycles_per_byte"] = events.cycles() / double(bench.bytes_per_iteration());
|
||||||
@@ -69,9 +70,11 @@ template<typename B, typename R> static void run_json_benchmark(benchmark::State
|
|||||||
|
|
||||||
state.counters["best_instructions"] = events.best.instructions();
|
state.counters["best_instructions"] = events.best.instructions();
|
||||||
state.counters["best_cycles"] = events.best.cycles();
|
state.counters["best_cycles"] = events.best.cycles();
|
||||||
|
#if !SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
state.counters["best_branch_miss"] = events.best.branch_misses();
|
state.counters["best_branch_miss"] = events.best.branch_misses();
|
||||||
state.counters["best_cache_miss"] = events.best.cache_misses();
|
state.counters["best_cache_miss"] = events.best.cache_misses();
|
||||||
state.counters["best_cache_ref"] = events.best.cache_references();
|
state.counters["best_cache_ref"] = events.best.cache_references();
|
||||||
|
#endif
|
||||||
|
|
||||||
state.counters["best_instructions_per_byte"] = events.best.instructions() / double(bench.bytes_per_iteration());
|
state.counters["best_instructions_per_byte"] = events.best.instructions() / double(bench.bytes_per_iteration());
|
||||||
state.counters["best_instructions_per_cycle"] = events.best.instructions() / events.best.cycles();
|
state.counters["best_instructions_per_cycle"] = events.best.instructions() / events.best.cycles();
|
||||||
@@ -92,9 +95,11 @@ template<typename B, typename R> static void run_json_benchmark(benchmark::State
|
|||||||
if (collector.has_events()) {
|
if (collector.has_events()) {
|
||||||
label << " instructions=" << setw(12) << uint64_t(events.best.instructions()) << setw(0);
|
label << " instructions=" << setw(12) << uint64_t(events.best.instructions()) << setw(0);
|
||||||
label << " cycles=" << setw(12) << uint64_t(events.best.cycles()) << setw(0);
|
label << " cycles=" << setw(12) << uint64_t(events.best.cycles()) << setw(0);
|
||||||
|
#if !SIMDJSON_SIMPLE_PERFORMANCE_COUNTERS
|
||||||
label << " branch_miss=" << setw(8) << uint64_t(events.best.branch_misses()) << setw(0);
|
label << " branch_miss=" << setw(8) << uint64_t(events.best.branch_misses()) << setw(0);
|
||||||
label << " cache_miss=" << setw(8) << uint64_t(events.best.cache_misses()) << setw(0);
|
label << " cache_miss=" << setw(8) << uint64_t(events.best.cache_misses()) << setw(0);
|
||||||
label << " cache_ref=" << setw(10) << uint64_t(events.best.cache_references()) << setw(0);
|
label << " cache_ref=" << setw(10) << uint64_t(events.best.cache_references()) << setw(0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
label << " items=" << setw(10) << bench.items_per_iteration() << setw(0);
|
label << " items=" << setw(10) << bench.items_per_iteration() << setw(0);
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
|
|
||||||
|
#include "kostya.h"
|
||||||
|
|
||||||
|
namespace kostya {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
struct nlohmann_json_sax {
|
||||||
|
static constexpr diff_flags DiffFlags = diff_flags::NONE;
|
||||||
|
|
||||||
|
struct Handler : json::json_sax_t
|
||||||
|
{
|
||||||
|
size_t k{0};
|
||||||
|
double buffer[3];
|
||||||
|
std::vector<point>& result;
|
||||||
|
|
||||||
|
Handler(std::vector<point>& r) : result(r) { }
|
||||||
|
|
||||||
|
bool key(string_t& val) override {
|
||||||
|
switch(val[0]) {
|
||||||
|
case 'x':
|
||||||
|
k = 0;
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
k = 1;
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
k = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_float(number_float_t val, const string_t& s) override {
|
||||||
|
buffer[k] = val;
|
||||||
|
if (k == 2) {
|
||||||
|
result.emplace_back(json_benchmark::point{buffer[0],buffer[1],buffer[2]});
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_unsigned(number_unsigned_t val) override { // Need this event because coordinate value can be equal to 1
|
||||||
|
buffer[k] = val;
|
||||||
|
if (k == 2) {
|
||||||
|
result.emplace_back(json_benchmark::point{buffer[0],buffer[1],buffer[2]});
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool null() override { return true; }
|
||||||
|
bool boolean(bool val) override { return true; }
|
||||||
|
bool number_integer(number_integer_t val) override { return true; }
|
||||||
|
bool string(string_t& val) override { return true; }
|
||||||
|
bool start_object(std::size_t elements) override { return true; }
|
||||||
|
bool end_object() override { return true; }
|
||||||
|
bool start_array(std::size_t elements) override { return true; }
|
||||||
|
bool end_array() override { return true; }
|
||||||
|
bool binary(json::binary_t& val) override { return true; }
|
||||||
|
bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override { return false; }
|
||||||
|
}; // Handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<point> &result) {
|
||||||
|
Handler handler(result);
|
||||||
|
json::sax_parse(json.data(), &handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // nlohmann_json_sax
|
||||||
|
BENCHMARK_TEMPLATE(kostya, nlohmann_json_sax)->UseManualTime();
|
||||||
|
} // namespace kostya
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|
||||||
|
#include "kostya.h"
|
||||||
|
|
||||||
|
namespace kostya {
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
|
||||||
|
struct rapidjson_sax {
|
||||||
|
static constexpr diff_flags DiffFlags = diff_flags::NONE;
|
||||||
|
|
||||||
|
struct Handler {
|
||||||
|
size_t k{0};
|
||||||
|
double buffer[3];
|
||||||
|
std::vector<point>& result;
|
||||||
|
|
||||||
|
Handler(std::vector<point> &r) : result(r) { }
|
||||||
|
|
||||||
|
bool Key(const char* key, SizeType length, bool copy) {
|
||||||
|
switch(key[0]) {
|
||||||
|
case 'x':
|
||||||
|
k = 0;
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
k = 1;
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
k = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Double(double d) {
|
||||||
|
buffer[k] = d;
|
||||||
|
if (k == 2) {
|
||||||
|
result.emplace_back(json_benchmark::point{buffer[0],buffer[1],buffer[2]});
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Uint(unsigned i) { return Double(i); } // Need this event because coordinate value can be equal to 1
|
||||||
|
// Irrelevant events
|
||||||
|
bool Null() { return true; }
|
||||||
|
bool Bool(bool b) { return true; }
|
||||||
|
bool Int(int i) { return true; }
|
||||||
|
bool Int64(int64_t i) { return true; }
|
||||||
|
bool Uint64(uint64_t i) { return true; }
|
||||||
|
bool RawNumber(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool String(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool StartObject() { return true; }
|
||||||
|
bool EndObject(SizeType memberCount) { return true; }
|
||||||
|
bool StartArray() { return true; }
|
||||||
|
bool EndArray(SizeType elementCount) { return true; }
|
||||||
|
}; // handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<point> &result) {
|
||||||
|
Reader reader;
|
||||||
|
Handler handler(result);
|
||||||
|
InsituStringStream ss(json.data());
|
||||||
|
reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag | kParseFullPrecisionFlag>(ss,handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // rapid_jason_sax
|
||||||
|
BENCHMARK_TEMPLATE(kostya, rapidjson_sax)->UseManualTime();
|
||||||
|
} // namespace kostya
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "json_benchmark/string_runner.h"
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace large_amazon_cellphones {
|
||||||
|
|
||||||
|
const bool UNTHREADED = false;
|
||||||
|
const bool THREADED = true;
|
||||||
|
|
||||||
|
static const simdjson::padded_string &get_built_json();
|
||||||
|
|
||||||
|
using namespace json_benchmark;
|
||||||
|
|
||||||
|
struct brand {
|
||||||
|
double cumulative_rating;
|
||||||
|
uint64_t reviews_count;
|
||||||
|
simdjson_really_inline bool operator==(const brand &other) const {
|
||||||
|
return cumulative_rating == other.cumulative_rating &&
|
||||||
|
reviews_count == other.reviews_count;
|
||||||
|
}
|
||||||
|
simdjson_really_inline bool operator!=(const brand &other) const { return !(*this == other); }
|
||||||
|
};
|
||||||
|
|
||||||
|
simdjson_unused static std::ostream &operator<<(std::ostream &o, const brand &b) {
|
||||||
|
o << "cumulative_rating: " << b.cumulative_rating << std::endl;
|
||||||
|
o << "reviews_count: " << b.reviews_count << std::endl;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename StringType>
|
||||||
|
simdjson_unused static std::ostream &operator<<(std::ostream &o, const std::pair<const StringType, brand> &p) {
|
||||||
|
o << "brand: " << p.first << std::endl;
|
||||||
|
o << p.second;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename I>
|
||||||
|
struct runner : public string_runner<I> {
|
||||||
|
std::map<typename I::StringType, brand> result{};
|
||||||
|
|
||||||
|
runner() : string_runner<I>(get_built_json()) {}
|
||||||
|
|
||||||
|
bool before_run(benchmark::State &state) {
|
||||||
|
if (!string_runner<I>::before_run(state)) { return false; }
|
||||||
|
result.clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool run(benchmark::State &) {
|
||||||
|
return this->implementation.run(this->json, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename R>
|
||||||
|
bool diff(benchmark::State &state, runner<R> &reference) {
|
||||||
|
return diff_results(state, result, reference.result, diff_flags::NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t items_per_iteration() {
|
||||||
|
return result.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string build_json(size_t N) {
|
||||||
|
std::ifstream in(AMAZON_CELLPHONES_NDJSON);
|
||||||
|
std::string answer((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
|
||||||
|
// Find position of first line to exclude it in further copies
|
||||||
|
size_t first_line = answer.find('\n');
|
||||||
|
std::string copy(answer,first_line + 1);
|
||||||
|
size_t count{1};
|
||||||
|
|
||||||
|
while (answer.size() < N) {
|
||||||
|
answer.append(copy);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Creating a source file spanning " << (answer.size() + 512) / (1024*1024) << " MB (" << count << " copies of original file)" << std::endl;
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const simdjson::padded_string &get_built_json() {
|
||||||
|
static simdjson::padded_string json = build_json(10*1024*1024);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool threaded>
|
||||||
|
struct simdjson_dom;
|
||||||
|
|
||||||
|
template<typename I> simdjson_really_inline static void large_amazon_cellphones(benchmark::State &state) {
|
||||||
|
run_json_benchmark<runner<I>, runner<simdjson_dom<UNTHREADED>>>(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace large_amazon_cellphones
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
#include "large_amazon_cellphones.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace large_amazon_cellphones {
|
||||||
|
|
||||||
|
using namespace simdjson;
|
||||||
|
|
||||||
|
template<bool threaded>
|
||||||
|
struct simdjson_dom {
|
||||||
|
using StringType = std::string;
|
||||||
|
|
||||||
|
dom::parser parser{};
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::map<StringType, brand> &result) {
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
parser.threaded = threaded;
|
||||||
|
#endif
|
||||||
|
auto stream = parser.parse_many(json);
|
||||||
|
auto i = stream.begin();
|
||||||
|
++i; // Skip first line
|
||||||
|
for (;i != stream.end(); ++i) {
|
||||||
|
auto doc = *i;
|
||||||
|
StringType copy(std::string_view(doc.at(1)));
|
||||||
|
auto x = result.find(copy);
|
||||||
|
if (x == result.end()) { // If key not found, add new key
|
||||||
|
result.emplace(copy, large_amazon_cellphones::brand{
|
||||||
|
double(doc.at(5)) * uint64_t(doc.at(7)),
|
||||||
|
uint64_t(doc.at(7))
|
||||||
|
});
|
||||||
|
} else { // Otherwise, update key data
|
||||||
|
x->second.cumulative_rating += double(doc.at(5)) * uint64_t(doc.at(7));
|
||||||
|
x->second.reviews_count += uint64_t(doc.at(7));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK_TEMPLATE(large_amazon_cellphones, simdjson_dom<UNTHREADED>)->UseManualTime();
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
BENCHMARK_TEMPLATE(large_amazon_cellphones, simdjson_dom<THREADED>)->UseManualTime();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace large_amazon_cellphones
|
||||||
|
|
||||||
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if SIMDJSON_EXCEPTIONS
|
||||||
|
|
||||||
|
#include "large_amazon_cellphones.h"
|
||||||
|
|
||||||
|
namespace large_amazon_cellphones {
|
||||||
|
|
||||||
|
using namespace simdjson;
|
||||||
|
|
||||||
|
template<bool threaded>
|
||||||
|
struct simdjson_ondemand {
|
||||||
|
using StringType = std::string;
|
||||||
|
|
||||||
|
ondemand::parser parser{};
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::map<StringType, brand> &result) {
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
parser.threaded = threaded;
|
||||||
|
#endif
|
||||||
|
ondemand::document_stream stream = parser.iterate_many(json);
|
||||||
|
ondemand::document_stream::iterator i = stream.begin();
|
||||||
|
++i; // Skip first line
|
||||||
|
for (;i != stream.end(); ++i) {
|
||||||
|
auto doc = *i;
|
||||||
|
size_t index{0};
|
||||||
|
StringType copy;
|
||||||
|
double rating;
|
||||||
|
uint64_t reviews;
|
||||||
|
for ( auto value : doc ) {
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
copy = StringType(std::string_view(value));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
rating = double(value);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
reviews = uint64_t(value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto x = result.find(copy);
|
||||||
|
if (x == result.end()) { // If key not found, add new key
|
||||||
|
result.emplace(copy, large_amazon_cellphones::brand{
|
||||||
|
rating * reviews,
|
||||||
|
reviews
|
||||||
|
});
|
||||||
|
} else { // Otherwise, update key data
|
||||||
|
x->second.cumulative_rating += rating * reviews;
|
||||||
|
x->second.reviews_count += reviews;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
BENCHMARK_TEMPLATE(large_amazon_cellphones, simdjson_ondemand<UNTHREADED>)->UseManualTime();
|
||||||
|
#ifdef SIMDJSON_THREADS_ENABLED
|
||||||
|
BENCHMARK_TEMPLATE(large_amazon_cellphones, simdjson_ondemand<THREADED>)->UseManualTime();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace amazon_cellphones
|
||||||
|
|
||||||
|
#endif // SIMDJSON_EXCEPTIONS
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
|
|
||||||
|
#include "large_random.h"
|
||||||
|
|
||||||
|
namespace large_random {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
struct nlohmann_json_sax {
|
||||||
|
static constexpr diff_flags DiffFlags = diff_flags::NONE;
|
||||||
|
|
||||||
|
struct Handler : json::json_sax_t
|
||||||
|
{
|
||||||
|
size_t k{0};
|
||||||
|
double buffer[3];
|
||||||
|
std::vector<point>& result;
|
||||||
|
|
||||||
|
Handler(std::vector<point> &r) : result(r) { }
|
||||||
|
|
||||||
|
bool key(string_t& val) override {
|
||||||
|
switch(val[0]) {
|
||||||
|
case 'x':
|
||||||
|
k = 0;
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
k = 1;
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
k = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_unsigned(number_unsigned_t val) override {
|
||||||
|
buffer[k] = val;
|
||||||
|
if (k == 2) {
|
||||||
|
result.emplace_back(json_benchmark::point{buffer[0],buffer[1],buffer[2]});
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_float(number_float_t val, const string_t& s) override {
|
||||||
|
buffer[k] = val;
|
||||||
|
if (k == 2) {
|
||||||
|
result.emplace_back(json_benchmark::point{buffer[0],buffer[1],buffer[2]});
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool null() override { return true; }
|
||||||
|
bool boolean(bool val) override { return true; }
|
||||||
|
bool number_integer(number_integer_t val) override { return true; }
|
||||||
|
bool string(string_t& val) override { return true; }
|
||||||
|
bool start_object(std::size_t elements) override { return true; }
|
||||||
|
bool end_object() override { return true; }
|
||||||
|
bool start_array(std::size_t elements) override { return true; }
|
||||||
|
bool end_array() override { return true; }
|
||||||
|
bool binary(json::binary_t& val) override { return true; }
|
||||||
|
bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override { return false; }
|
||||||
|
}; // Handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<point> &result) {
|
||||||
|
Handler handler(result);
|
||||||
|
json::sax_parse(json.data(), &handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // nlohmann_json_sax
|
||||||
|
BENCHMARK_TEMPLATE(large_random, nlohmann_json_sax)->UseManualTime();
|
||||||
|
} // namespace large_random
|
||||||
|
#endif // SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|
||||||
|
#include "large_random.h"
|
||||||
|
|
||||||
|
namespace large_random {
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
|
||||||
|
struct rapidjson_sax {
|
||||||
|
static constexpr diff_flags DiffFlags = diff_flags::NONE;
|
||||||
|
|
||||||
|
struct Handler {
|
||||||
|
size_t k{0};
|
||||||
|
double buffer[3];
|
||||||
|
std::vector<point>& result;
|
||||||
|
|
||||||
|
Handler(std::vector<point> &r) : result(r) { }
|
||||||
|
|
||||||
|
bool Key(const char* key, SizeType length, bool copy) {
|
||||||
|
switch(key[0]) {
|
||||||
|
case 'x':
|
||||||
|
k = 0;
|
||||||
|
break;
|
||||||
|
case 'y':
|
||||||
|
k = 1;
|
||||||
|
break;
|
||||||
|
case 'z':
|
||||||
|
k = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Double(double d) {
|
||||||
|
buffer[k] = d;
|
||||||
|
if (k == 2) {
|
||||||
|
result.emplace_back(json_benchmark::point{buffer[0],buffer[1],buffer[2]});
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Uint(unsigned i) { return Double(i); } // Need this event because coordinate value can be equal to 1
|
||||||
|
// Irrelevant events
|
||||||
|
bool Null() { return true; }
|
||||||
|
bool Bool(bool b) { return true; }
|
||||||
|
bool Int(int i) { return true; }
|
||||||
|
bool Int64(int64_t i) { return true; }
|
||||||
|
bool Uint64(uint64_t i) { return true; }
|
||||||
|
bool RawNumber(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool String(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool StartObject() { return true; }
|
||||||
|
bool EndObject(SizeType memberCount) { return true; }
|
||||||
|
bool StartArray() { return true; }
|
||||||
|
bool EndArray(SizeType elementCount) { return true; }
|
||||||
|
}; // handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<point> &result) {
|
||||||
|
Reader reader;
|
||||||
|
Handler handler(result);
|
||||||
|
InsituStringStream ss(json.data());
|
||||||
|
reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag | kParseFullPrecisionFlag>(ss,handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // rapid_jason_sax
|
||||||
|
BENCHMARK_TEMPLATE(large_random, rapidjson_sax)->UseManualTime();
|
||||||
|
} // namespace large_random
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
@@ -29,6 +29,7 @@ template <int TYPE = PERF_TYPE_HARDWARE> class LinuxEvents {
|
|||||||
size_t num_events{};
|
size_t num_events{};
|
||||||
std::vector<uint64_t> temp_result_vec{};
|
std::vector<uint64_t> temp_result_vec{};
|
||||||
std::vector<uint64_t> result{};
|
std::vector<uint64_t> result{};
|
||||||
|
std::vector<int> fds{};
|
||||||
bool quiet;
|
bool quiet;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -52,10 +53,12 @@ public:
|
|||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for (auto config : config_vec) {
|
for (auto config : config_vec) {
|
||||||
attribs.config = config;
|
attribs.config = config;
|
||||||
fd = static_cast<int>(syscall(__NR_perf_event_open, &attribs, pid, cpu, group, flags));
|
int _fd = static_cast<int>(syscall(__NR_perf_event_open, &attribs, pid, cpu, group, flags));
|
||||||
if (fd == -1) {
|
if (_fd == -1) {
|
||||||
report_error("perf_event_open");
|
report_error("perf_event_open");
|
||||||
}
|
}
|
||||||
|
fd = _fd; // fd tracks the last _fd value.
|
||||||
|
fds.push_back(fd);
|
||||||
ioctl(fd, PERF_EVENT_IOC_ID, &result[i++]);
|
ioctl(fd, PERF_EVENT_IOC_ID, &result[i++]);
|
||||||
if (group == -1) {
|
if (group == -1) {
|
||||||
group = fd;
|
group = fd;
|
||||||
@@ -65,7 +68,11 @@ public:
|
|||||||
temp_result_vec.resize(num_events * 2 + 1);
|
temp_result_vec.resize(num_events * 2 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
~LinuxEvents() { if (fd != -1) { close(fd); } }
|
~LinuxEvents() {
|
||||||
|
for (auto tfd : fds) {
|
||||||
|
if (tfd != -1) { close(tfd); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline void start() {
|
inline void start() {
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
|
|
||||||
|
#include "partial_tweets.h"
|
||||||
|
|
||||||
|
namespace partial_tweets {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
struct nlohmann_json_sax {
|
||||||
|
using StringType=std::string;
|
||||||
|
|
||||||
|
struct Handler : json::json_sax_t
|
||||||
|
{
|
||||||
|
// 8 keys to parse for each tweet (in order of appearance): "created_at", "id", "text", "in_reply_status_id", "id"(user),
|
||||||
|
// "screen_name"(user), "retweet_count" and "favorite_count".
|
||||||
|
// Assume that the first valid key encountered will be the correct key to parse.
|
||||||
|
// Assume that each tweet/retweet start with a key "metadata" and has a key "retweeted" towards the end
|
||||||
|
// The previous assumption will be used to check for the beginning of a new tweet and the end of a retweet
|
||||||
|
enum state { // Bitset to store state of search
|
||||||
|
key_date = (1<<0),
|
||||||
|
key_id = (1<<1),
|
||||||
|
key_text = (1<<2),
|
||||||
|
key_reply = (1<<3),
|
||||||
|
key_userid = (1<<4),
|
||||||
|
key_screenname = (1<<5),
|
||||||
|
key_rt = (1<<6),
|
||||||
|
key_fav = (1<<7),
|
||||||
|
found_date = (1<<8),
|
||||||
|
found_id = (1<<9),
|
||||||
|
found_text = (1<<10),
|
||||||
|
found_reply = (1<<11),
|
||||||
|
found_userid = (1<<12),
|
||||||
|
found_screenname = (1<<13),
|
||||||
|
found_rt = (1<<14),
|
||||||
|
found_fav = (1<<15)
|
||||||
|
};
|
||||||
|
int values = state::key_date;
|
||||||
|
bool userobject_id = false; // If in a user object (to find user.id)
|
||||||
|
bool userobject_screen_name = false; // If in a user object (to find user.screen_name)
|
||||||
|
bool inretweet = false; // If in a retweet (all keys irrelevant in retweet object)
|
||||||
|
// Fields to store partial tweet info
|
||||||
|
uint64_t user_id;
|
||||||
|
uint64_t id;
|
||||||
|
uint64_t rt;
|
||||||
|
uint64_t fav;
|
||||||
|
uint64_t reply_status;
|
||||||
|
string_t screen_name;
|
||||||
|
string_t date;
|
||||||
|
string_t text;
|
||||||
|
std::vector<tweet<std::string>>& result;
|
||||||
|
|
||||||
|
Handler(std::vector<tweet<std::string>> &r) : result(r) { }
|
||||||
|
|
||||||
|
bool key(string_t& val) override {
|
||||||
|
if (!inretweet) { // If not in a retweet object, find relevant keys
|
||||||
|
if (val.compare("retweeted_status") == 0) { inretweet = true; } // Check if entering retweet
|
||||||
|
else if (val.compare("metadata") == 0) { values = 0; } // Reset
|
||||||
|
// Check if key has been found and if key matches a valid key
|
||||||
|
else if (!(values & found_date) && (val.compare("created_at") == 0)) { values |= (key_date); }
|
||||||
|
// Must also check if not in a user object
|
||||||
|
else if (!(values & found_id) && !userobject_id && (val.compare("id") == 0)) { values |= (key_id); }
|
||||||
|
else if (!(values & found_text) && (val.compare("text") == 0)) { values |= (key_text); }
|
||||||
|
else if (!(values & found_reply) && (val.compare("in_reply_to_status_id") == 0)) { values |= (key_reply); }
|
||||||
|
// Check if entering user object
|
||||||
|
else if ((val.compare("user") == 0)) { userobject_id = userobject_screen_name = true; }
|
||||||
|
// Must also check if in a user object
|
||||||
|
else if (!(values & found_userid) && userobject_id && (val.compare("id") == 0)) { values |= (key_userid); }
|
||||||
|
// Must also check if in a user object
|
||||||
|
else if (!(values & found_screenname) && userobject_screen_name && (val.compare("screen_name") == 0)) { values |= (key_screenname); }
|
||||||
|
else if (!(values & found_rt) && (val.compare("retweet_count") == 0)) { values |= (key_rt); }
|
||||||
|
else if (!(values & found_fav) && (val.compare("favorite_count") == 0)) { values |= (key_fav); }
|
||||||
|
}
|
||||||
|
else if (val.compare("retweeted") == 0) { inretweet = false; } // Check if end of retweet
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_unsigned(number_unsigned_t val) override {
|
||||||
|
if (values & key_id && !(values & found_id)) { // id
|
||||||
|
id = val;
|
||||||
|
values &= ~(key_id);
|
||||||
|
values |= (found_id);
|
||||||
|
}
|
||||||
|
else if (values & key_reply && !(values & found_reply)) { // in_reply_status_id
|
||||||
|
reply_status = val;
|
||||||
|
values &= ~(key_reply);
|
||||||
|
values |= (found_reply);
|
||||||
|
}
|
||||||
|
else if (values & key_userid && !(values & found_userid)) { // user.id
|
||||||
|
user_id = val;
|
||||||
|
userobject_id = false;
|
||||||
|
values &= ~(key_userid);
|
||||||
|
values |= (found_userid);
|
||||||
|
}
|
||||||
|
else if (values & key_rt && !(values & found_rt)) { // retweet_count
|
||||||
|
rt = val;
|
||||||
|
values &= ~(key_rt);
|
||||||
|
values |= (found_rt);
|
||||||
|
}
|
||||||
|
else if (values & key_fav && !(values & found_fav)) { // favorite_count
|
||||||
|
fav = val;
|
||||||
|
values &= ~(key_fav);
|
||||||
|
values |= (found_fav);
|
||||||
|
// Assume that this is last key required, so add the partial_tweet to result
|
||||||
|
result.emplace_back(partial_tweets::tweet<std::string>{
|
||||||
|
date,id,text,reply_status,{user_id,screen_name},rt,fav});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool string(string_t& val) override {
|
||||||
|
if (values & key_date && !(values & found_date)) { // created_at
|
||||||
|
date = val;
|
||||||
|
values &= ~(key_date);
|
||||||
|
values |= (found_date);
|
||||||
|
}
|
||||||
|
else if (values & key_text && !(values & found_text)) { // text
|
||||||
|
text = val;
|
||||||
|
values &= ~(key_text);
|
||||||
|
values |= (found_text);
|
||||||
|
}
|
||||||
|
else if (values & key_screenname && !(values & found_screenname)) { // user.screen_name
|
||||||
|
screen_name = val;
|
||||||
|
userobject_screen_name = false;
|
||||||
|
values &= ~(key_screenname);
|
||||||
|
values |= (found_screenname);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool null() override {
|
||||||
|
if (values & key_reply && !(values & found_reply)) { // in_reply_status (null case)
|
||||||
|
reply_status = 0;
|
||||||
|
values &= ~(key_reply);
|
||||||
|
values |= (found_reply);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool boolean(bool val) override { return true; }
|
||||||
|
bool number_float(number_float_t val, const string_t& s) override { return true; }
|
||||||
|
bool number_integer(number_integer_t val) override { return true; }
|
||||||
|
bool start_object(std::size_t elements) override { return true; }
|
||||||
|
bool end_object() override { return true; }
|
||||||
|
bool start_array(std::size_t elements) override { return true; }
|
||||||
|
bool end_array() override { return true; }
|
||||||
|
bool binary(json::binary_t& val) override { return true; }
|
||||||
|
bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override { return false; }
|
||||||
|
}; // Handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<tweet<std::string>> &result) {
|
||||||
|
Handler handler(result);
|
||||||
|
json::sax_parse(json.data(), &handler);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // nlohmann_json_sax
|
||||||
|
BENCHMARK_TEMPLATE(partial_tweets, nlohmann_json_sax)->UseManualTime();
|
||||||
|
} // namespace partial_tweets
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|
||||||
|
#include "partial_tweets.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
namespace partial_tweets {
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
|
||||||
|
struct rapidjson_sax {
|
||||||
|
using StringType=std::string_view;
|
||||||
|
|
||||||
|
// 8 keys to parse for each tweet (in order of appearance): "created_at", "id", "text", "in_reply_status_id", "id"(user),
|
||||||
|
// "screen_name"(user), "retweet_count" and "favorite_count".
|
||||||
|
// Assume that the first valid key encountered will be the correct key to parse.
|
||||||
|
// Assume that each tweet/retweet start with a key "metadata" and has a key "retweeted" towards the end
|
||||||
|
// The previous assumption will be used to check for the beginning of a new tweet and the end of a retweet
|
||||||
|
struct Handler {
|
||||||
|
enum state { // Bitset to store state of search
|
||||||
|
key_date = (1<<0),
|
||||||
|
key_id = (1<<1),
|
||||||
|
key_text = (1<<2),
|
||||||
|
key_reply = (1<<3),
|
||||||
|
key_userid = (1<<4),
|
||||||
|
key_screenname = (1<<5),
|
||||||
|
key_rt = (1<<6),
|
||||||
|
key_fav = (1<<7),
|
||||||
|
found_date = (1<<8),
|
||||||
|
found_id = (1<<9),
|
||||||
|
found_text = (1<<10),
|
||||||
|
found_reply = (1<<11),
|
||||||
|
found_userid = (1<<12),
|
||||||
|
found_screenname = (1<<13),
|
||||||
|
found_rt = (1<<14),
|
||||||
|
found_fav = (1<<15)
|
||||||
|
};
|
||||||
|
int values = state::key_date;
|
||||||
|
bool userobject_id = false; // If in a user object (to find user.id)
|
||||||
|
bool userobject_screen_name = false; // If in a user object (to find user.screen_name)
|
||||||
|
bool inretweet = false; // If in a retweet (all keys irrelevant in retweet object)
|
||||||
|
// Fields to store partial tweet info
|
||||||
|
uint64_t user_id;
|
||||||
|
uint64_t id;
|
||||||
|
uint64_t rt;
|
||||||
|
uint64_t fav;
|
||||||
|
uint64_t reply_status;
|
||||||
|
std::string_view screen_name;
|
||||||
|
std::string_view date;
|
||||||
|
std::string_view text;
|
||||||
|
std::vector<tweet<std::string_view>>& result;
|
||||||
|
|
||||||
|
Handler(std::vector<tweet<std::string_view>> &r) : result(r) { }
|
||||||
|
|
||||||
|
bool Key(const char* key, SizeType length, bool copy) {
|
||||||
|
if (!inretweet) { // If not in a retweet object, find relevant keys
|
||||||
|
if ((length == 16) && (memcmp(key,"retweeted_status",16) == 0)) { inretweet = true; } // Check if entering retweet
|
||||||
|
else if ((length == 8) && (memcmp(key,"metadata",8) == 0)) { values = 0; } // Reset
|
||||||
|
// Check if key has been found and if key matches a valid key
|
||||||
|
else if (!(values & found_date) && (length == 10) && (memcmp(key,"created_at",10) == 0)) { values |= (key_date); }
|
||||||
|
// Must also check if not in a user object
|
||||||
|
else if (!(values & found_id) && !userobject_id && (length == 2) && (memcmp(key,"id",2) == 0)) { values |= (key_id); }
|
||||||
|
else if (!(values & found_text) && (length == 4) && (memcmp(key,"text",4) == 0)) { values |= (key_text); }
|
||||||
|
else if (!(values & found_reply) && (length == 21) && (memcmp(key,"in_reply_to_status_id",21) == 0)) { values |= (key_reply); }
|
||||||
|
// Check if entering user object
|
||||||
|
else if ((length == 4) && (memcmp(key,"user",4) == 0)) { userobject_id = userobject_screen_name = true; }
|
||||||
|
// Must also check if in a user object
|
||||||
|
else if (!(values & found_userid) && userobject_id && (length == 2) && (memcmp(key,"id",2) == 0)) { values |= (key_userid); }
|
||||||
|
// Must also check if in a user object
|
||||||
|
else if (!(values & found_screenname) && userobject_screen_name && (length == 11) && (memcmp(key,"screen_name",11) == 0)) { values |= (key_screenname); }
|
||||||
|
else if (!(values & found_rt) && (length == 13) && (memcmp(key,"retweet_count",13) == 0)) { values |= (key_rt); }
|
||||||
|
else if (!(values & found_fav) && (length == 14) && (memcmp(key,"favorite_count",14) == 0)) { values |= (key_fav); }
|
||||||
|
}
|
||||||
|
else if ((length == 9) && (memcmp(key,"retweeted",9) == 0)) { inretweet = false; } // Check if end of retweet
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Uint(unsigned i) {
|
||||||
|
if (values & key_userid && !(values & found_userid)) { // user.id
|
||||||
|
user_id = i;
|
||||||
|
userobject_id = false;
|
||||||
|
values &= ~(key_userid);
|
||||||
|
values |= (found_userid);
|
||||||
|
}
|
||||||
|
else if (values & key_rt && !(values & found_rt)) { // retweet_count
|
||||||
|
rt = i;
|
||||||
|
values &= ~(key_rt);
|
||||||
|
values |= (found_rt);
|
||||||
|
}
|
||||||
|
else if (values & key_fav && !(values & found_fav)) { // favorite_count
|
||||||
|
fav = i;
|
||||||
|
values &= ~(key_fav);
|
||||||
|
values |= (found_fav);
|
||||||
|
// Assume that this is last key required, so add the partial_tweet to result
|
||||||
|
result.emplace_back(partial_tweets::tweet<std::string_view>{
|
||||||
|
date,id,text,reply_status,{user_id,screen_name},rt,fav});
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Uint64(uint64_t i) {
|
||||||
|
if (values & key_id && !(values & found_id)) { // id
|
||||||
|
id = i;
|
||||||
|
values &= ~(key_id);
|
||||||
|
values |= (found_id);
|
||||||
|
}
|
||||||
|
else if (values & key_reply && !(values & found_reply)) { // in_reply_status_id
|
||||||
|
reply_status = i;
|
||||||
|
values &= ~(key_reply);
|
||||||
|
values |= (found_reply);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool String(const char* str, SizeType length, bool copy) {
|
||||||
|
if (values & key_date && !(values & found_date)) { // created_at
|
||||||
|
date = {str,length};
|
||||||
|
values &= ~(key_date);
|
||||||
|
values |= (found_date);
|
||||||
|
}
|
||||||
|
else if (values & key_text && !(values & found_text)) { // text
|
||||||
|
text = {str,length};
|
||||||
|
values &= ~(key_text);
|
||||||
|
values |= (found_text);
|
||||||
|
}
|
||||||
|
else if (values & key_screenname && !(values & found_screenname)) { // user.screen_name
|
||||||
|
screen_name = {str,length};
|
||||||
|
userobject_screen_name = false;
|
||||||
|
values &= ~(key_screenname);
|
||||||
|
values |= (found_screenname);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Null() {
|
||||||
|
if (values & key_reply && !(values & found_reply)) { // in_reply_status (null case)
|
||||||
|
reply_status = 0;
|
||||||
|
values &= ~(key_reply);
|
||||||
|
values |= (found_reply);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool Bool(bool b) { return true; }
|
||||||
|
bool Double(double d) { return true; }
|
||||||
|
bool Int(int i) { return true; }
|
||||||
|
bool Int64(int64_t i) { return true; }
|
||||||
|
bool RawNumber(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool StartObject() { return true; }
|
||||||
|
bool EndObject(SizeType memberCount) { return true; }
|
||||||
|
bool StartArray() { return true; }
|
||||||
|
bool EndArray(SizeType elementCount) { return true; }
|
||||||
|
}; // handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, std::vector<tweet<std::string_view>> &result) {
|
||||||
|
Reader reader;
|
||||||
|
Handler handler(result);
|
||||||
|
InsituStringStream ss(json.data());
|
||||||
|
reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag | kParseFullPrecisionFlag>(ss,handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}; // rapid_jason_sax
|
||||||
|
BENCHMARK_TEMPLATE(partial_tweets, rapidjson_sax)->UseManualTime();
|
||||||
|
} // namespace partial_tweets
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
|
|
||||||
|
#include "top_tweet.h"
|
||||||
|
|
||||||
|
namespace top_tweet {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
struct nlohmann_json_sax {
|
||||||
|
using StringType=std::string;
|
||||||
|
|
||||||
|
struct Handler : json::json_sax_t
|
||||||
|
{
|
||||||
|
// Assume every tweet/retweet starts with "metadata" key and ends with "retweeted" key. Ignore everything in a retweet.
|
||||||
|
// Assume that the first valid key encountered outside a retweet is the correct key.
|
||||||
|
enum state { // Bitset to store state of search
|
||||||
|
key_text = (1<<0),
|
||||||
|
key_screen_name = (1<<1),
|
||||||
|
key_rt = (1<<2),
|
||||||
|
found_text = (1<<3),
|
||||||
|
found_screen_name = (1<<4),
|
||||||
|
found_rt = (1<<5)
|
||||||
|
};
|
||||||
|
int values = state::key_text;
|
||||||
|
bool userobject = false; // If in a user object
|
||||||
|
bool inretweet = false;
|
||||||
|
int64_t max_rt;
|
||||||
|
int rt;
|
||||||
|
string_t screen_name;
|
||||||
|
string_t text;
|
||||||
|
top_tweet_result<StringType>& result;
|
||||||
|
|
||||||
|
Handler(top_tweet_result<StringType> &r,int64_t m) : result(r), max_rt(m) { }
|
||||||
|
|
||||||
|
bool key(string_t& val) override {
|
||||||
|
if (!inretweet) { // If not in a retweet object, find relevant keys
|
||||||
|
if (val.compare("retweeted_status") == 0) { inretweet = true; } // Check if entering retweet
|
||||||
|
else if (val.compare("metadata") == 0) { values = 0; } // Reset
|
||||||
|
else if (!(values & found_text) && (val.compare("text") == 0)) { values |= (key_text); }
|
||||||
|
else if ((val.compare("user") == 0)) { userobject = true; }
|
||||||
|
else if (!(values & found_screen_name) && userobject && (val.compare("screen_name") == 0)) { values |= (key_screen_name); }
|
||||||
|
else if (!(values & found_rt) && (val.compare("retweet_count") == 0)) { values |= (key_rt); }
|
||||||
|
}
|
||||||
|
else if (val.compare("retweeted") == 0) { inretweet = false; } // Check if end of retweet
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool number_unsigned(number_unsigned_t val) override {
|
||||||
|
if (values & key_rt && !(values & found_rt)) { // retweet_count
|
||||||
|
rt = val;
|
||||||
|
values &= ~(key_rt);
|
||||||
|
values |= (found_rt);
|
||||||
|
if (rt <= max_rt && rt >= result.retweet_count) { // Check if current tweet has more retweet than previous top tweet
|
||||||
|
result.retweet_count = rt;
|
||||||
|
result.text = text;
|
||||||
|
result.screen_name = screen_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool string(string_t& val) override {
|
||||||
|
if (values & key_text && !(values & found_text)) { // text
|
||||||
|
text = val;
|
||||||
|
values &= ~(key_text);
|
||||||
|
values |= (found_text);
|
||||||
|
}
|
||||||
|
else if (values & key_screen_name && !(values & found_screen_name)) { // user.screen_name
|
||||||
|
screen_name = val;
|
||||||
|
userobject = false;
|
||||||
|
values &= ~(key_screen_name);
|
||||||
|
values |= (found_screen_name);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool null() override { return true; }
|
||||||
|
bool boolean(bool val) override { return true; }
|
||||||
|
bool number_float(number_float_t val, const string_t& s) override { return true; }
|
||||||
|
bool number_integer(number_integer_t val) override { return true; }
|
||||||
|
bool start_object(std::size_t elements) override { return true; }
|
||||||
|
bool end_object() override { return true; }
|
||||||
|
bool start_array(std::size_t elements) override { return true; }
|
||||||
|
bool end_array() override { return true; }
|
||||||
|
bool binary(json::binary_t& val) override { return true; }
|
||||||
|
bool parse_error(std::size_t position, const std::string& last_token, const json::exception& ex) override { return false; }
|
||||||
|
}; // Handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, int64_t max_retweet_count, top_tweet_result<StringType> &result) {
|
||||||
|
result.retweet_count = -1;
|
||||||
|
Handler handler(result,max_retweet_count);
|
||||||
|
json::sax_parse(json.data(), &handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // nlohmann_json_sax
|
||||||
|
BENCHMARK_TEMPLATE(top_tweet, nlohmann_json_sax)->UseManualTime();
|
||||||
|
} // namespace top_tweet
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_NLOHMANN_JSON
|
||||||
@@ -64,6 +64,6 @@ struct rapidjson_insitu : rapidjson_base {
|
|||||||
};
|
};
|
||||||
BENCHMARK_TEMPLATE(top_tweet, rapidjson_insitu)->UseManualTime();
|
BENCHMARK_TEMPLATE(top_tweet, rapidjson_insitu)->UseManualTime();
|
||||||
|
|
||||||
} // namespace partial_tweets
|
} // namespace top_tweet
|
||||||
|
|
||||||
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
|
|
||||||
|
#include "top_tweet.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace top_tweet {
|
||||||
|
|
||||||
|
using namespace rapidjson;
|
||||||
|
|
||||||
|
struct rapidjson_sax {
|
||||||
|
using StringType=std::string_view;
|
||||||
|
struct Handler {
|
||||||
|
// Assume every tweet/retweet starts with "metadata" key and ends with "retweeted" key. Ignore everything in a retweet.
|
||||||
|
// Assume that the first valid key encountered outside a retweet is the correct key.
|
||||||
|
enum state { // Bit set to keep track of state of search for keys
|
||||||
|
key_text = (1<<0),
|
||||||
|
key_screen_name = (1<<1),
|
||||||
|
key_rt = (1<<2),
|
||||||
|
found_text = (1<<3),
|
||||||
|
found_screen_name = (1<<4),
|
||||||
|
found_rt = (1<<5)
|
||||||
|
};
|
||||||
|
int values = state::key_text;
|
||||||
|
int rt;
|
||||||
|
StringType text;
|
||||||
|
StringType screen_name;
|
||||||
|
bool inretweet = false;
|
||||||
|
bool userobject = false;
|
||||||
|
top_tweet_result<StringType>& result;
|
||||||
|
int64_t max_rt;
|
||||||
|
|
||||||
|
Handler(top_tweet_result<StringType> &r,int64_t m) : result(r), max_rt(m) { }
|
||||||
|
|
||||||
|
bool Key(const char* key, SizeType length, bool copy) {
|
||||||
|
if (!inretweet) {
|
||||||
|
if ((length == 16) && (memcmp(key,"retweeted_status",16) == 0)) { inretweet = true; } // Check if entering retweet
|
||||||
|
else if ((length == 8) && (memcmp(key,"metadata",8) == 0)) { values = 0; } // Reset
|
||||||
|
else if (!(values & found_text) && (length == 4) && (memcmp(key,"text",4) == 0)) { values |= (key_text); }
|
||||||
|
else if ((length == 4) && (memcmp(key,"user",4) == 0)) { userobject = true; }
|
||||||
|
else if (!(values & found_screen_name) && userobject && (length == 11) && memcmp(key,"screen_name",11) == 0) { values |= (key_screen_name); }
|
||||||
|
else if (!(values & found_rt) && (length == 13) && (memcmp(key,"retweet_count",13) == 0)) { values |= (key_rt); }
|
||||||
|
}
|
||||||
|
else if ((length == 9) && (memcmp(key,"retweeted",9) == 0)) { inretweet = false; } // Check if end of retweet
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool String(const char* str, SizeType length, bool copy) {
|
||||||
|
if (values & key_text && !(values & found_text)) { // text
|
||||||
|
text = {str,length};
|
||||||
|
values &= ~(key_text);
|
||||||
|
values |= (found_text);
|
||||||
|
}
|
||||||
|
else if (values & key_screen_name && !(values & found_screen_name)) { // user.screen_name
|
||||||
|
screen_name = {str,length};
|
||||||
|
values &= ~(key_screen_name);
|
||||||
|
values |= (found_screen_name);
|
||||||
|
userobject = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Uint(unsigned i) {
|
||||||
|
if (values & key_rt && !(values & found_rt)) { // retweet_count
|
||||||
|
rt = i;
|
||||||
|
values &= ~(key_rt);
|
||||||
|
values |= (found_rt);
|
||||||
|
if (rt <= max_rt && rt >= result.retweet_count) { // Check if current tweet has more retweet than previous top tweet
|
||||||
|
result.retweet_count = rt;
|
||||||
|
result.text = text;
|
||||||
|
result.screen_name = screen_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Irrelevant events
|
||||||
|
bool Null() { return true; }
|
||||||
|
bool Bool(bool b) { return true; }
|
||||||
|
bool Double(double d) { return true; }
|
||||||
|
bool Int(int i) { return true; }
|
||||||
|
bool Int64(int64_t i) { return true; }
|
||||||
|
bool Uint64(uint64_t i) { return true; }
|
||||||
|
bool RawNumber(const char* str, SizeType length, bool copy) { return true; }
|
||||||
|
bool StartObject() { return true; }
|
||||||
|
bool EndObject(SizeType memberCount) { return true; }
|
||||||
|
bool StartArray() { return true; }
|
||||||
|
bool EndArray(SizeType elementCount) { return true; }
|
||||||
|
}; // handler
|
||||||
|
|
||||||
|
bool run(simdjson::padded_string &json, int64_t max_retweet_count, top_tweet_result<StringType> &result) {
|
||||||
|
result.retweet_count = -1;
|
||||||
|
Reader reader;
|
||||||
|
Handler handler(result,max_retweet_count);
|
||||||
|
InsituStringStream ss(json.data());
|
||||||
|
reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag | kParseFullPrecisionFlag>(ss,handler);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}; // rapidjson_sax
|
||||||
|
BENCHMARK_TEMPLATE(top_tweet, rapidjson_sax)->UseManualTime();
|
||||||
|
} // namespace top_tweet
|
||||||
|
|
||||||
|
#endif // SIMDJSON_COMPETITION_RAPIDJSON
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
#
|
||||||
|
# Flags used by exes and by the simdjson library (project-wide flags)
|
||||||
|
#
|
||||||
|
add_library(simdjson-internal-flags INTERFACE)
|
||||||
|
|
||||||
|
|
||||||
|
option(SIMDJSON_CHECK_EOF "Check for the end of the input buffer. The setting is unnecessary since we require padding of the inputs. You should expect tests to fail with this option turned on." OFF)
|
||||||
|
if(SIMDJSON_CHECK_EOF)
|
||||||
|
add_compile_definitions(SIMDJSON_CHECK_EOF=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(SIMDJSON_SANITIZE_UNDEFINED "Sanitize undefined behavior" OFF)
|
||||||
|
if(SIMDJSON_SANITIZE_UNDEFINED)
|
||||||
|
add_compile_options(-fsanitize=undefined -fno-sanitize-recover=all)
|
||||||
|
add_link_options(-fsanitize=undefined -fno-sanitize-recover=all)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(SIMDJSON_SANITIZE "Sanitize addresses" OFF)
|
||||||
|
if(SIMDJSON_SANITIZE)
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||||
|
message(STATUS "The address sanitizer under Apple's clang appears to be \
|
||||||
|
incompatible with the undefined-behavior sanitizer.")
|
||||||
|
message(STATUS "You may set SIMDJSON_SANITIZE_UNDEFINED to sanitize \
|
||||||
|
undefined behavior.")
|
||||||
|
add_compile_options(
|
||||||
|
-fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all
|
||||||
|
)
|
||||||
|
add_compile_definitions(ASAN_OPTIONS=detect_leaks=1)
|
||||||
|
link_libraries(
|
||||||
|
-fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(
|
||||||
|
STATUS
|
||||||
|
"Setting both the address sanitizer and the undefined sanitizer."
|
||||||
|
)
|
||||||
|
add_compile_options(
|
||||||
|
-fsanitize=address -fno-omit-frame-pointer
|
||||||
|
-fsanitize=undefined -fno-sanitize-recover=all
|
||||||
|
)
|
||||||
|
link_libraries(
|
||||||
|
-fsanitize=address -fno-omit-frame-pointer
|
||||||
|
-fsanitize=undefined -fno-sanitize-recover=all
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Ubuntu bug for GCC 5.0+ (safe for all versions)
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
link_libraries(-fuse-ld=gold)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIMDJSON_SANITIZE_THREADS)
|
||||||
|
message(STATUS "Setting both the thread sanitizer \
|
||||||
|
and the undefined-behavior sanitizer.")
|
||||||
|
add_compile_options(
|
||||||
|
-fsanitize=thread -fsanitize=undefined -fno-sanitize-recover=all
|
||||||
|
)
|
||||||
|
link_libraries(
|
||||||
|
-fsanitize=thread -fsanitize=undefined -fno-sanitize-recover=all
|
||||||
|
)
|
||||||
|
|
||||||
|
# Ubuntu bug for GCC 5.0+ (safe for all versions)
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
link_libraries(-fuse-ld=gold)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
|
||||||
|
if(NOT is_multi_config AND NOT CMAKE_BUILD_TYPE)
|
||||||
|
# Deliberately not including SIMDJSON_SANITIZE_THREADS since thread behavior
|
||||||
|
# depends on the build type.
|
||||||
|
if(SIMDJSON_SANITIZE OR SIMDJSON_SANITIZE_UNDEFINED)
|
||||||
|
message(STATUS "No build type selected and you have enabled the sanitizer, \
|
||||||
|
default to Debug. Consider setting CMAKE_BUILD_TYPE.")
|
||||||
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
|
||||||
|
else()
|
||||||
|
message(STATUS "No build type selected, default to Release")
|
||||||
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
option(SIMDJSON_USE_LIBCPP "Use the libc++ library" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
|
# This will require special handling.
|
||||||
|
set(SIMDJSON_WINDOWS_DLL TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# We compile tools, tests, etc. with C++ 17. Override yourself if you need on a
|
||||||
|
# target.
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
set(CMAKE_MACOSX_RPATH OFF)
|
||||||
|
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
|
||||||
|
# LTO seems to create all sorts of fun problems. Let us
|
||||||
|
# disable temporarily.
|
||||||
|
#include(CheckIPOSupported)
|
||||||
|
#check_ipo_supported(RESULT ltoresult)
|
||||||
|
#if(ltoresult)
|
||||||
|
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
option(SIMDJSON_VISUAL_STUDIO_BUILD_WITH_DEBUG_INFO_FOR_PROFILING "\
|
||||||
|
Under Visual Studio, add Zi to the compile flag and DEBUG to the link file to \
|
||||||
|
add debugging information to the release build for easier profiling inside \
|
||||||
|
tools like VTune" OFF)
|
||||||
|
if(MSVC)
|
||||||
|
if(MSVC_TOOLSET_VERSION STRLESS "142")
|
||||||
|
set(SIMDJSON_LEGACY_VISUAL_STUDIO TRUE)
|
||||||
|
message (STATUS "A legacy Visual Studio version was detected. \
|
||||||
|
We recommend Visual Studio 2019 or better on a 64-bit system.")
|
||||||
|
endif()
|
||||||
|
if(MSVC_TOOLSET_VERSION STREQUAL "140")
|
||||||
|
# Visual Studio 2015 issues warnings and we tolerate it
|
||||||
|
# cmake -G "Visual Studio 14" ..
|
||||||
|
target_compile_options(simdjson-internal-flags INTERFACE /W0 /sdl)
|
||||||
|
else()
|
||||||
|
# Recent version of Visual Studio expected (2017, 2019...). Prior versions
|
||||||
|
# are unsupported.
|
||||||
|
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4714?view=vs-2019
|
||||||
|
target_compile_options(simdjson-internal-flags INTERFACE /WX /W3 /sdl /w34714)
|
||||||
|
if(MSVC_VERSION GREATER 1910)
|
||||||
|
target_compile_options(simdjson-internal-flags INTERFACE /permissive-)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(SIMDJSON_VISUAL_STUDIO_BUILD_WITH_DEBUG_INFO_FOR_PROFILING)
|
||||||
|
add_link_options(/DEBUG)
|
||||||
|
add_compile_options(/Zi)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(NOT WIN32)
|
||||||
|
target_compile_options(simdjson-internal-flags INTERFACE -fPIC)
|
||||||
|
endif()
|
||||||
|
target_compile_options(
|
||||||
|
simdjson-internal-flags INTERFACE
|
||||||
|
-Werror -Wall -Wextra -Weffc++ -Wsign-compare -Wshadow -Wwrite-strings
|
||||||
|
-Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Other optional flags
|
||||||
|
#
|
||||||
|
option(SIMDJSON_BASH "Allow usage of bash within CMake" ON)
|
||||||
|
|
||||||
|
option(
|
||||||
|
SIMDJSON_VERBOSE_LOGGING
|
||||||
|
"Enable verbose logging for internal simdjson library development."
|
||||||
|
OFF
|
||||||
|
)
|
||||||
|
if(SIMDJSON_VERBOSE_LOGGING)
|
||||||
|
add_compile_definitions(SIMDJSON_VERBOSE_LOGGING=1
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(SIMDJSON_USE_LIBCPP)
|
||||||
|
link_libraries(-stdlib=libc++ -lc++abi)
|
||||||
|
# instead of the above line, we could have used
|
||||||
|
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++
|
||||||
|
# -lc++abi")
|
||||||
|
# The next line is needed empirically.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
|
# we update CMAKE_SHARED_LINKER_FLAGS, this gets updated later as well
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lc++abi")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# prevent shared libraries from depending on Intel provided libraries
|
||||||
|
if(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(
|
||||||
|
SIMDJSON_AVX512_ALLOWED
|
||||||
|
"Enable AVX-512 instructions (only affects processors and compilers with AVX-512 support)."
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
if(SIMDJSON_AVX512_ALLOWED)
|
||||||
|
add_compile_definitions(SIMDJSON_AVX512_ALLOWED=1)
|
||||||
|
else()
|
||||||
|
add_compile_definitions(SIMDJSON_AVX512_ALLOWED=0)
|
||||||
|
message(STATUS "AVX-512 instructions are not allowed.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
check_symbol_exists(fork unistd.h HAVE_POSIX_FORK)
|
||||||
|
check_symbol_exists(wait sys/wait.h HAVE_POSIX_WAIT)
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
option(SIMDJSON_EXCEPTIONS "Enable simdjson's exception-throwing interface" ON)
|
||||||
|
if(NOT SIMDJSON_EXCEPTIONS)
|
||||||
|
message(STATUS "simdjson exception interface turned off. \
|
||||||
|
Code that does not check error codes will not compile.")
|
||||||
|
simdjson_add_props(target_compile_definitions PUBLIC SIMDJSON_EXCEPTIONS=0)
|
||||||
|
if(MSVC)
|
||||||
|
if(NOT is_top_project)
|
||||||
|
message(AUTHOR_WARNING "Turning SIMDJSON_EXCEPTIONS off requires \
|
||||||
|
editing CMAKE_CXX_FLAGS")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# CMake currently /EHsc as a default flag in CMAKE_CXX_FLAGS on MSVC.
|
||||||
|
# Replacing this with a more general abstraction is a WIP
|
||||||
|
# (see https://gitlab.kitware.com/cmake/cmake/-/issues/20610)
|
||||||
|
# /EHs enables standard C++ stack unwinding when catching exceptions
|
||||||
|
# (non-structured exception handling)
|
||||||
|
# /EHc used in conjection with /EHs indicates that extern "C" functions
|
||||||
|
# never throw (terminate-on-throw)
|
||||||
|
# Here, we disable both with the - argument negation operator
|
||||||
|
string(REPLACE "/EHsc" "/EHs-c-" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||||
|
|
||||||
|
# Because we cannot change the flag above on an individual target (yet), the
|
||||||
|
# definition below must similarly be added globally
|
||||||
|
add_definitions(-D_HAS_EXCEPTIONS=0)
|
||||||
|
elseif(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
simdjson_add_props(target_link_libraries PRIVATE -fno-exceptions)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
if(DEFINED SIMDJSON_BUILD_STATIC)
|
||||||
|
message(DEPRECATION "SIMDJSON_BUILD_STATIC is deprecated, setting \
|
||||||
|
BUILD_SHARED_LIBS with its value and unsetting it")
|
||||||
|
set(shared ON)
|
||||||
|
if(SIMDJSON_BUILD_STATIC)
|
||||||
|
set(shared OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(BUILD_SHARED_LIBS "${shared}" CACHE BOOL "" FORCE)
|
||||||
|
unset(SIMDJSON_BUILD_STATIC CACHE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED SIMDJSON_JUST_LIBRARY)
|
||||||
|
message(DEPRECATION "SIMDJSON_JUST_LIBRARY is deprecated, setting \
|
||||||
|
SIMDJSON_DEVELOPER_MODE with its value and unsetting it")
|
||||||
|
set(dev_mode ON)
|
||||||
|
if(SIMDJSON_JUST_LIBRARY)
|
||||||
|
set(dev_mode OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SIMDJSON_DEVELOPER_MODE "${dev_mode}" CACHE BOOL "" FORCE)
|
||||||
|
unset(SIMDJSON_JUST_LIBRARY CACHE)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#
|
||||||
|
# Implementation selection
|
||||||
|
#
|
||||||
|
set(SIMDJSON_ALL_IMPLEMENTATIONS fallback westmere haswell icelake arm64 ppc64)
|
||||||
|
|
||||||
|
set(
|
||||||
|
SIMDJSON_IMPLEMENTATION ""
|
||||||
|
CACHE STRING "\
|
||||||
|
Semicolon-separated list of implementations to include \
|
||||||
|
(${SIMDJSON_ALL_IMPLEMENTATIONS}). If this is not set, any implementations \
|
||||||
|
that are supported at compile time and may be selected at runtime will be \
|
||||||
|
included."
|
||||||
|
)
|
||||||
|
set(
|
||||||
|
SIMDJSON_EXCLUDE_IMPLEMENTATION ""
|
||||||
|
CACHE STRING "\
|
||||||
|
Semicolon-separated list of implementations to exclude \
|
||||||
|
(icelake/haswell/westmere/arm64/ppc64/fallback). By default, excludes any \
|
||||||
|
implementations that are unsupported at compile time or cannot be selected at \
|
||||||
|
runtime."
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(var IN ITEMS IMPLEMENTATION EXCLUDE_IMPLEMENTATION)
|
||||||
|
set(var "SIMDJSON_${var}")
|
||||||
|
foreach(impl IN LISTS "${var}")
|
||||||
|
if(NOT impl IN_LIST SIMDJSON_ALL_IMPLEMENTATIONS)
|
||||||
|
message(ERROR "\
|
||||||
|
Implementation ${impl} found in ${var} not supported by simdjson. \
|
||||||
|
Possible implementations: ${SIMDJSON_ALL_IMPLEMENTATIONS}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
macro(flag_action action var val)
|
||||||
|
message(STATUS "${action} implementation ${impl} due to ${var}=${${var}}")
|
||||||
|
simdjson_add_props(
|
||||||
|
target_compile_definitions PUBLIC
|
||||||
|
"SIMDJSON_IMPLEMENTATION_${impl_upper}=${val}"
|
||||||
|
)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
foreach(impl IN LISTS SIMDJSON_ALL_IMPLEMENTATIONS)
|
||||||
|
string(TOUPPER "${impl}" impl_upper)
|
||||||
|
if(impl IN_LIST SIMDJSON_EXCLUDE_IMPLEMENTATION)
|
||||||
|
flag_action(Excluding SIMDJSON_EXCLUDE_IMPLEMENTATION 0)
|
||||||
|
elseif(impl IN_LIST SIMDJSON_IMPLEMENTATION)
|
||||||
|
flag_action(Including SIMDJSON_IMPLEMENTATION 1)
|
||||||
|
elseif(SIMDJSON_IMPLEMENTATION)
|
||||||
|
flag_action(Excluding SIMDJSON_IMPLEMENTATION 0)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# TODO make it so this generates the necessary compiler flags to select the
|
||||||
|
# given impl as the builtin automatically!
|
||||||
|
set(
|
||||||
|
SIMDJSON_BUILTIN_IMPLEMENTATION ""
|
||||||
|
CACHE STRING "\
|
||||||
|
Select the implementation that will be used for user code. Defaults to the \
|
||||||
|
most universal implementation in SIMDJSON_IMPLEMENTATION (in the order \
|
||||||
|
${SIMDJSON_ALL_IMPLEMENTATIONS}) if specified; otherwise, by default the \
|
||||||
|
compiler will pick the best implementation that can always be selected given \
|
||||||
|
the compiler flags."
|
||||||
|
)
|
||||||
|
if(NOT SIMDJSON_BUILTIN_IMPLEMENTATION STREQUAL "")
|
||||||
|
simdjson_add_props(
|
||||||
|
target_compile_definitions PUBLIC
|
||||||
|
"SIMDJSON_BUILTIN_IMPLEMENTATION=${SIMDJSON_BUILTIN_IMPLEMENTATION}"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# Pick the most universal implementation out of the selected implementations
|
||||||
|
# (if any)
|
||||||
|
foreach(impl IN LISTS SIMDJSON_ALL_IMPLEMENTATIONS)
|
||||||
|
if(
|
||||||
|
impl IN_LIST SIMDJSON_IMPLEMENTATION
|
||||||
|
AND NOT impl IN_LIST SIMDJSON_EXCLUDE_IMPLEMENTATION
|
||||||
|
)
|
||||||
|
message(STATUS "\
|
||||||
|
Selected implementation ${impl} as builtin implementation based on \
|
||||||
|
${SIMDJSON_IMPLEMENTATION}")
|
||||||
|
simdjson_add_props(
|
||||||
|
target_compile_definitions PUBLIC
|
||||||
|
"SIMDJSON_BUILTIN_IMPLEMENTATION=${impl}"
|
||||||
|
)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(impl IN LISTS SIMDJSON_ALL_IMPLEMENTATIONS)
|
||||||
|
string(TOUPPER "${impl}" impl_upper)
|
||||||
|
option(
|
||||||
|
"SIMDJSON_IMPLEMENTATION_${impl_upper}"
|
||||||
|
"Include the ${impl} implementation"
|
||||||
|
ON
|
||||||
|
)
|
||||||
|
mark_as_advanced("SIMDJSON_IMPLEMENTATION_${impl_upper}")
|
||||||
|
if(NOT "${SIMDJSON_IMPLEMENTATION_${impl_upper}}")
|
||||||
|
message(DEPRECATION "\
|
||||||
|
SIMDJSON_IMPLEMENTATION_${impl_upper} is deprecated. \
|
||||||
|
Use SIMDJSON_IMPLEMENTATION=-${impl} instead")
|
||||||
|
simdjson_add_props(
|
||||||
|
target_compile_definitions PUBLIC
|
||||||
|
"SIMDJSON_IMPLEMENTATION_${impl_upper}=0"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
@PACKAGE_INIT@
|
|
||||||
|
|
||||||
include(CMakeFindDependencyMacro)
|
include(CMakeFindDependencyMacro)
|
||||||
if(@SIMDJSON_ENABLE_THREADS@)
|
if("@SIMDJSON_ENABLE_THREADS@")
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
find_dependency(Threads)
|
||||||
find_dependency(Threads)
|
|
||||||
endif()
|
endif()
|
||||||
# Import targets.
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/simdjsonTargets.cmake")
|
||||||
|
|||||||
@@ -1,275 +0,0 @@
|
|||||||
|
|
||||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
||||||
message (STATUS "The simdjson repository appears to be standalone.")
|
|
||||||
option(SIMDJSON_JUST_LIBRARY "Build just the library, omit tests, tools and benchmarks" OFF)
|
|
||||||
message (STATUS "By default, we attempt to build everything.")
|
|
||||||
else()
|
|
||||||
message (STATUS "The simdjson repository appears to be used as a subdirectory.")
|
|
||||||
option(SIMDJSON_JUST_LIBRARY "Build just the library, omit tests, tools and benchmarks" ON)
|
|
||||||
message (STATUS "By default, we just build the library.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#
|
|
||||||
# Flags used by exes and by the simdjson library (project-wide flags)
|
|
||||||
#
|
|
||||||
add_library(simdjson-flags INTERFACE)
|
|
||||||
add_library(simdjson-internal-flags INTERFACE)
|
|
||||||
target_link_libraries(simdjson-internal-flags INTERFACE simdjson-flags)
|
|
||||||
|
|
||||||
option(SIMDJSON_SANITIZE_UNDEFINED "Sanitize undefined behavior" OFF)
|
|
||||||
if(SIMDJSON_SANITIZE_UNDEFINED)
|
|
||||||
target_compile_options(simdjson-flags INTERFACE -fsanitize=undefined -fno-sanitize-recover=all)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -fsanitize=undefined -fno-sanitize-recover=all)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(SIMDJSON_SANITIZE "Sanitize addresses" OFF)
|
|
||||||
if(SIMDJSON_SANITIZE)
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
message(STATUS "The address sanitizer under Apple's clang appears to be incompatible with the undefined-behavior sanitizer.")
|
|
||||||
message(STATUS "You may set SIMDJSON_SANITIZE_UNDEFINED to sanitize undefined behavior.")
|
|
||||||
target_compile_options(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all)
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE ASAN_OPTIONS=detect_leaks=1)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all)
|
|
||||||
else()
|
|
||||||
message(STATUS "Setting both the address sanitizer and the undefined sanitizer.")
|
|
||||||
target_compile_options(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all)
|
|
||||||
endif()
|
|
||||||
# Ubuntu bug for GCC 5.0+ (safe for all versions)
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCC)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -fuse-ld=gold)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(SIMDJSON_SANITIZE_THREADS)
|
|
||||||
message(STATUS "Setting both the thread sanitizer and the undefined-behavior sanitizer.")
|
|
||||||
target_compile_options(simdjson-flags INTERFACE -fsanitize=thread -fsanitize=undefined -fno-sanitize-recover=all)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -fsanitize=thread -fsanitize=undefined -fno-sanitize-recover=all)
|
|
||||||
|
|
||||||
# Ubuntu bug for GCC 5.0+ (safe for all versions)
|
|
||||||
if (CMAKE_COMPILER_IS_GNUCC)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -fuse-ld=gold)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE)
|
|
||||||
# Deliberately not including SIMDJSON_SANITIZE_THREADS since thread behavior depends on the build type.
|
|
||||||
if(SIMDJSON_SANITIZE OR SIMDJSON_SANITIZE_UNDEFINED)
|
|
||||||
message(STATUS "No build type selected and you have enabled the sanitizer, default to Debug. Consider setting CMAKE_BUILD_TYPE.")
|
|
||||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
|
|
||||||
else()
|
|
||||||
message(STATUS "No build type selected, default to Release")
|
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
option(SIMDJSON_BUILD_STATIC "Build a static library" ON) # turning it on disables the production of a dynamic library
|
|
||||||
else()
|
|
||||||
option(SIMDJSON_BUILD_STATIC "Build a static library" OFF) # turning it on disables the production of a dynamic library
|
|
||||||
option(SIMDJSON_USE_LIBCPP "Use the libc++ library" OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC AND NOT(SIMDJSON_BUILD_STATIC))
|
|
||||||
# This will require special handling.
|
|
||||||
set(SIMDJSON_WINDOWS_DLL TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
|
|
||||||
|
|
||||||
# We compile tools, tests, etc. with C++ 17. Override yourself if you need on a target.
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
||||||
set(CMAKE_MACOSX_RPATH OFF)
|
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
||||||
|
|
||||||
# LTO seems to create all sorts of fun problems. Let us
|
|
||||||
# disable temporarily.
|
|
||||||
#include(CheckIPOSupported)
|
|
||||||
#check_ipo_supported(RESULT ltoresult)
|
|
||||||
#if(ltoresult)
|
|
||||||
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
option(SIMDJSON_VISUAL_STUDIO_BUILD_WITH_DEBUG_INFO_FOR_PROFILING "Under Visual Studio, add Zi to the compile flag and DEBUG to the link file to add debugging information to the release build for easier profiling inside tools like VTune" OFF)
|
|
||||||
if(MSVC)
|
|
||||||
if("${MSVC_TOOLSET_VERSION}" STRLESS "142")
|
|
||||||
set(SIMDJSON_LEGACY_VISUAL_STUDIO TRUE)
|
|
||||||
message (STATUS "A legacy Visual Studio version was detected. We recommend Visual Studio 2019 or better on a 64-bit system.")
|
|
||||||
endif()
|
|
||||||
if("${MSVC_TOOLSET_VERSION}" STREQUAL "140")
|
|
||||||
# Visual Studio 2015 issues warnings and we tolerate it, cmake -G"Visual Studio 14" ..
|
|
||||||
target_compile_options(simdjson-internal-flags INTERFACE /W0 /sdl)
|
|
||||||
else()
|
|
||||||
# Recent version of Visual Studio expected (2017, 2019...). Prior versions are unsupported.
|
|
||||||
target_compile_options(simdjson-internal-flags INTERFACE /WX /W3 /sdl /w34714) # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4714?view=vs-2019
|
|
||||||
endif()
|
|
||||||
if(SIMDJSON_VISUAL_STUDIO_BUILD_WITH_DEBUG_INFO_FOR_PROFILING)
|
|
||||||
target_link_options(simdjson-flags INTERFACE /DEBUG )
|
|
||||||
target_compile_options(simdjson-flags INTERFACE /Zi)
|
|
||||||
endif(SIMDJSON_VISUAL_STUDIO_BUILD_WITH_DEBUG_INFO_FOR_PROFILING)
|
|
||||||
else(MSVC)
|
|
||||||
if(NOT WIN32)
|
|
||||||
target_compile_options(simdjson-internal-flags INTERFACE -fPIC)
|
|
||||||
endif()
|
|
||||||
target_compile_options(simdjson-internal-flags INTERFACE -Werror -Wall -Wextra -Weffc++)
|
|
||||||
target_compile_options(simdjson-internal-flags INTERFACE -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion)
|
|
||||||
endif(MSVC)
|
|
||||||
|
|
||||||
|
|
||||||
# workaround for GNU GCC poor AVX load/store code generation
|
|
||||||
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86(_64)?)$"))
|
|
||||||
target_compile_options(simdjson-flags INTERFACE -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#
|
|
||||||
# Optional flags
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Implementation selection
|
|
||||||
#
|
|
||||||
set(SIMDJSON_ALL_IMPLEMENTATIONS "fallback;westmere;haswell;arm64;ppc64")
|
|
||||||
|
|
||||||
set(SIMDJSON_IMPLEMENTATION "" CACHE STRING "Semicolon-separated list of implementations to include (${SIMDJSON_ALL_IMPLEMENTATIONS}). If this is not set, any implementations that are supported at compile time and may be selected at runtime will be included.")
|
|
||||||
foreach(implementation ${SIMDJSON_IMPLEMENTATION})
|
|
||||||
if(NOT (implementation IN_LIST SIMDJSON_ALL_IMPLEMENTATIONS))
|
|
||||||
message(ERROR "Implementation ${implementation} not supported by simdjson. Possible implementations: ${SIMDJSON_ALL_IMPLEMENTATIONS}")
|
|
||||||
endif()
|
|
||||||
endforeach(implementation)
|
|
||||||
|
|
||||||
set(SIMDJSON_EXCLUDE_IMPLEMENTATION "" CACHE STRING "Semicolon-separated list of implementations to exclude (haswell/westmere/arm64/ppc64/fallback). By default, excludes any implementations that are unsupported at compile time or cannot be selected at runtime.")
|
|
||||||
foreach(implementation ${SIMDJSON_EXCLUDE_IMPLEMENTATION})
|
|
||||||
if(NOT (implementation IN_LIST SIMDJSON_ALL_IMPLEMENTATIONS))
|
|
||||||
message(ERROR "Implementation ${implementation} not supported by simdjson. Possible implementations: ${SIMDJSON_ALL_IMPLEMENTATIONS}")
|
|
||||||
endif()
|
|
||||||
endforeach(implementation)
|
|
||||||
|
|
||||||
foreach(implementation ${SIMDJSON_ALL_IMPLEMENTATIONS})
|
|
||||||
string(TOUPPER ${implementation} implementation_upper)
|
|
||||||
if(implementation IN_LIST SIMDJSON_EXCLUDE_IMPLEMENTATION)
|
|
||||||
message(STATUS "Excluding implementation ${implementation} due to SIMDJSON_EXCLUDE_IMPLEMENTATION=${SIMDJSON_EXCLUDE_IMPLEMENTATION}")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE "SIMDJSON_IMPLEMENTATION_${implementation_upper}=0")
|
|
||||||
elseif(implementation IN_LIST SIMDJSON_IMPLEMENTATION)
|
|
||||||
message(STATUS "Including implementation ${implementation} due to SIMDJSON_IMPLEMENTATION=${SIMDJSON_IMPLEMENTATION}")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE "SIMDJSON_IMPLEMENTATION_${implementation_upper}=1")
|
|
||||||
elseif(SIMDJSON_IMPLEMENTATION)
|
|
||||||
message(STATUS "Excluding implementation ${implementation} due to SIMDJSON_IMPLEMENTATION=${SIMDJSON_IMPLEMENTATION}")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE "SIMDJSON_IMPLEMENTATION_${implementation_upper}=0")
|
|
||||||
endif()
|
|
||||||
endforeach(implementation)
|
|
||||||
|
|
||||||
# TODO make it so this generates the necessary compiler flags to select the given implementation as the builtin automatically!
|
|
||||||
option(SIMDJSON_BUILTIN_IMPLEMENTATION "Select the implementation that will be used for user code. Defaults to the most universal implementation in SIMDJSON_IMPLEMENTATION (in the order ${SIMDJSON_ALL_IMPLEMENTATIONS}) if specified; otherwise, by default the compiler will pick the best implementation that can always be selected given the compiler flags." "")
|
|
||||||
if(SIMDJSON_BUILTIN_IMPLEMENTATION)
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE "SIMDJSON_BUILTIN_IMPLEMENTATION=${SIMDJSON_BUILTIN_IMPLEMENTATION}")
|
|
||||||
else()
|
|
||||||
# Pick the most universal implementation out of the selected implementations (if any)
|
|
||||||
foreach(implementation ${SIMDJSON_ALL_IMPLEMENTATIONS})
|
|
||||||
if(implementation IN_LIST SIMDJSON_IMPLEMENTATION AND NOT (implementation IN_LIST SIMDJSON_EXCLUDE_IMPLEMENTATION))
|
|
||||||
message(STATUS "Selected implementation ${implementation} as builtin implementation based on ${SIMDJSON_IMPLEMENTATION}.")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE "SIMDJSON_BUILTIN_IMPLEMENTATION=${implementation}")
|
|
||||||
break()
|
|
||||||
endif()
|
|
||||||
endforeach(implementation)
|
|
||||||
endif(SIMDJSON_BUILTIN_IMPLEMENTATION)
|
|
||||||
|
|
||||||
option(SIMDJSON_IMPLEMENTATION_HASWELL "Include the haswell implementation" ON)
|
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_HASWELL)
|
|
||||||
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_HASWELL is deprecated. Use SIMDJSON_IMPLEMENTATION=-haswell instead.")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_HASWELL=0)
|
|
||||||
endif()
|
|
||||||
option(SIMDJSON_IMPLEMENTATION_WESTMERE "Include the westmere implementation" ON)
|
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_WESTMERE)
|
|
||||||
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_WESTMERE is deprecated. SIMDJSON_IMPLEMENTATION=-westmere instead.")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_WESTMERE=0)
|
|
||||||
endif()
|
|
||||||
option(SIMDJSON_IMPLEMENTATION_ARM64 "Include the arm64 implementation" ON)
|
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_ARM64)
|
|
||||||
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_ARM64 is deprecated. Use SIMDJSON_IMPLEMENTATION=-arm64 instead.")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_ARM64=0)
|
|
||||||
endif()
|
|
||||||
option(SIMDJSON_IMPLEMENTATION_PPC64 "Include the arm64 implementation" ON)
|
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_PPC64)
|
|
||||||
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_PPC64 is deprecated. Use SIMDJSON_IMPLEMENTATION=-ppc64 instead.")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_PPC64=0)
|
|
||||||
endif()
|
|
||||||
option(SIMDJSON_IMPLEMENTATION_FALLBACK "Include the fallback implementation" ON)
|
|
||||||
if(NOT SIMDJSON_IMPLEMENTATION_FALLBACK)
|
|
||||||
message(DEPRECATION "SIMDJSON_IMPLEMENTATION_FALLBACK is deprecated. Use SIMDJSON_IMPLEMENTATION=-fallback instead.")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_IMPLEMENTATION_FALLBACK=0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#
|
|
||||||
# Other optional flags
|
|
||||||
#
|
|
||||||
option(SIMDJSON_DEVELOPMENT_CHECKS "Enable development-time aids, such as checks for incorrect API usage. Enabled by default in DEBUG." OFF)
|
|
||||||
if(SIMDJSON_DEVELOPMENT_CHECKS)
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_DEVELOPMENT_CHECKS)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(SIMDJSON_BASH "Allow usage of bash within CMake" ON)
|
|
||||||
|
|
||||||
option(SIMDJSON_EXCEPTIONS "Enable simdjson's exception-throwing interface" ON)
|
|
||||||
if(NOT SIMDJSON_EXCEPTIONS)
|
|
||||||
message(STATUS "simdjson exception interface turned off. Code that does not check error codes will not compile.")
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_EXCEPTIONS=0)
|
|
||||||
if(MSVC)
|
|
||||||
# CMake currently /EHsc as a default flag in CMAKE_CXX_FLAGS on MSVC. Replacing this with a more general abstraction is a WIP (see https://gitlab.kitware.com/cmake/cmake/-/issues/20610)
|
|
||||||
# /EHs enables standard C++ stack unwinding when catching exceptions (non-structured exception handling)
|
|
||||||
# /EHc used in conjection with /EHs indicates that extern "C" functions never throw (terminate-on-throw)
|
|
||||||
# Here, we disable both with the - argument negation operator
|
|
||||||
string(REPLACE "/EHsc" "/EHs-c-" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
||||||
|
|
||||||
# Because we cannot change the flag above on an invidual target (yet), the definition below must similarly be added globally
|
|
||||||
add_definitions(-D_HAS_EXCEPTIONS=0)
|
|
||||||
elseif (CMAKE_COMPILER_IS_GNUCC)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -fno-exceptions)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(SIMDJSON_ENABLE_THREADS "Link with thread support" ON)
|
|
||||||
if(SIMDJSON_ENABLE_THREADS)
|
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE Threads::Threads)
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_THREADS_ENABLED=1) # This will be set in the code automatically.
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(SIMDJSON_VERBOSE_LOGGING, "Enable verbose logging for internal simdjson library development." OFF)
|
|
||||||
if (SIMDJSON_VERBOSE_LOGGING)
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_VERBOSE_LOGGING=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(SIMDJSON_DISABLE_DEPRECATED_API "Disables deprecated APIs" Off)
|
|
||||||
if (SIMDJSON_DISABLE_DEPRECATED_API)
|
|
||||||
target_compile_definitions(simdjson-flags INTERFACE SIMDJSON_DISABLE_DEPRECATED_API=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SIMDJSON_USE_LIBCPP)
|
|
||||||
target_link_libraries(simdjson-flags INTERFACE -stdlib=libc++ -lc++abi)
|
|
||||||
# instead of the above line, we could have used
|
|
||||||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
|
|
||||||
# The next line is needed empirically.
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
|
||||||
# we update CMAKE_SHARED_LINKER_FLAGS, this gets updated later as well
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lc++abi")
|
|
||||||
endif(SIMDJSON_USE_LIBCPP)
|
|
||||||
|
|
||||||
# prevent shared libraries from depending on Intel provided libraries
|
|
||||||
if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include (CheckSymbolExists)
|
|
||||||
CHECK_SYMBOL_EXISTS(fork unistd.h HAVE_POSIX_FORK)
|
|
||||||
CHECK_SYMBOL_EXISTS(wait sys/wait.h HAVE_POSIX_WAIT)
|
|
||||||
|
|
||||||
install(TARGETS simdjson-flags EXPORT simdjson-config)
|
|
||||||
|
|
||||||
# I do not think we want to export our internal flags!
|
|
||||||
# install(TARGETS simdjson-internal-flags EXPORT simdjson-config)
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#
|
||||||
|
# Accumulate flags
|
||||||
|
#
|
||||||
|
set(simdjson_props_script "${PROJECT_BINARY_DIR}/simdjson-props.cmake")
|
||||||
|
set(simdjson_props_content "")
|
||||||
|
set(simdjson_props_flushed NO)
|
||||||
|
|
||||||
|
function(simdjson_add_props command)
|
||||||
|
set(args "")
|
||||||
|
math(EXPR limit "${ARGC} - 1")
|
||||||
|
foreach(i RANGE 1 "${limit}")
|
||||||
|
set(value "${ARGV${i}}")
|
||||||
|
if(value MATCHES "^(PRIVATE|PUBLIC)$")
|
||||||
|
string(TOLOWER "${value}" value)
|
||||||
|
set(value "\${${value}}")
|
||||||
|
else()
|
||||||
|
set(value "[==[${value}]==]")
|
||||||
|
endif()
|
||||||
|
string(APPEND args " ${value}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(simdjson_props_flushed NO PARENT_SCOPE)
|
||||||
|
set(
|
||||||
|
simdjson_props_content
|
||||||
|
"${simdjson_props_content}${command}(\"\${target}\"${args})\n"
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
macro(simdjson_flush_props)
|
||||||
|
if(NOT simdjson_props_flushed)
|
||||||
|
set(simdjson_props_flushed YES PARENT_SCOPE)
|
||||||
|
file(WRITE "${simdjson_props_script}" "${simdjson_props_content}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
function(simdjson_apply_props target)
|
||||||
|
set(private PRIVATE)
|
||||||
|
set(public PUBLIC)
|
||||||
|
get_target_property(TYPE "${target}" TYPE)
|
||||||
|
if(TYPE STREQUAL "INTERFACE_LIBRARY")
|
||||||
|
set(private INTERFACE)
|
||||||
|
set(public INTERFACE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
simdjson_flush_props()
|
||||||
|
include("${simdjson_props_script}")
|
||||||
|
endfunction()
|
||||||
@@ -1,24 +1,19 @@
|
|||||||
#
|
#
|
||||||
# ${SIMDJSON_USER_CMAKECACHE} contains the *user-specified* simdjson options so you can call cmake on
|
# ${USER_CMAKECACHE} contains the *user-specified* simdjson options so you can
|
||||||
# another branch or repository with the same options.
|
# call cmake on another branch or repository with the same options.
|
||||||
#
|
#
|
||||||
# Not supported on Windows at present, because the only thing that uses it is checkperf, which we
|
|
||||||
# don't run on Windows.
|
file(READ "${BINARY_DIR}/CMakeCache.txt" cache)
|
||||||
#
|
# Escape semicolons, so the lines can be safely iterated in CMake
|
||||||
set(SIMDJSON_USER_CMAKECACHE ${CMAKE_CURRENT_BINARY_DIR}/.simdjson-user-CMakeCache.txt)
|
string(REPLACE ";" "\\;" cache "${cache}")
|
||||||
if (MSVC)
|
# Turn the contents into a list
|
||||||
add_custom_command(
|
string(REPLACE "\n" ";" cache "${cache}")
|
||||||
OUTPUT ${SIMDJSON_USER_CMAKECACHE}
|
|
||||||
COMMAND findstr SIMDJSON_ ${PROJECT_BINARY_DIR}/CMakeCache.txt > ${SIMDJSON_USER_CMAKECACHE}.tmp
|
message(STATUS "${USER_CMAKECACHE}")
|
||||||
COMMAND findstr /v SIMDJSON_LIB_ ${SIMDJSON_USER_CMAKECACHE}.tmp > ${SIMDJSON_USER_CMAKECACHE}
|
|
||||||
VERBATIM # Makes it not do weird escaping with the command
|
file(REMOVE "${USER_CMAKECACHE}")
|
||||||
)
|
foreach(line IN LISTS cache)
|
||||||
else()
|
if(line MATCHES "^SIMDJSON_" AND NOT line MATCHES "^SIMDJSON_LIB_")
|
||||||
add_custom_command(
|
file(APPEND "${USER_CMAKECACHE}" "${line}\n")
|
||||||
OUTPUT ${SIMDJSON_USER_CMAKECACHE}
|
endif()
|
||||||
COMMAND grep SIMDJSON_ ${PROJECT_BINARY_DIR}/CMakeCache.txt > ${SIMDJSON_USER_CMAKECACHE}.tmp
|
endforeach()
|
||||||
COMMAND grep -v SIMDJSON_LIB_ ${SIMDJSON_USER_CMAKECACHE}.tmp > ${SIMDJSON_USER_CMAKECACHE}
|
|
||||||
VERBATIM # Makes it not do weird escaping with the command
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
add_custom_target(simdjson-user-cmakecache DEPENDS ${SIMDJSON_USER_CMAKECACHE})
|
|
||||||
|
|||||||
Vendored
+6
-1
@@ -13,11 +13,16 @@ cmake_dependent_option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark
|
|||||||
if(SIMDJSON_GOOGLE_BENCHMARKS)
|
if(SIMDJSON_GOOGLE_BENCHMARKS)
|
||||||
set_off(BENCHMARK_ENABLE_TESTING)
|
set_off(BENCHMARK_ENABLE_TESTING)
|
||||||
set_off(BENCHMARK_ENABLE_INSTALL)
|
set_off(BENCHMARK_ENABLE_INSTALL)
|
||||||
|
set_off(BENCHMARK_ENABLE_WERROR)
|
||||||
|
|
||||||
import_dependency(google_benchmarks google/benchmark 8982e1e)
|
import_dependency(google_benchmarks google/benchmark f91b6b4)
|
||||||
add_dependency(google_benchmarks)
|
add_dependency(google_benchmarks)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# The bulk of our benchmarking and testing data has been moved simdjson/simdjson-data
|
||||||
|
import_dependency(simdjson-data simdjson/simdjson-data a5b13babe65c1bba7186b41b43d4cbdc20a5c470)
|
||||||
|
add_dependency(simdjson-data)
|
||||||
|
|
||||||
# This prevents variables declared with set() from unnecessarily escaping and
|
# This prevents variables declared with set() from unnecessarily escaping and
|
||||||
# should not be called more than once
|
# should not be called more than once
|
||||||
function(competition_scope_)
|
function(competition_scope_)
|
||||||
|
|||||||
+1063
-442
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
|||||||
|
We take our documentation seriously. Please start reading the documentation before you attempt to use simdjson. We hope you will enjoy reading us.
|
||||||
|
|
||||||
* Basics: https://github.com/simdjson/simdjson/blob/master/doc/basics.md is an overview of how to use simdjson and its APIs.
|
* Basics: https://github.com/simdjson/simdjson/blob/master/doc/basics.md is an overview of how to use simdjson and its APIs.
|
||||||
* parse_many: https://github.com/simdjson/simdjson/blob/master/doc/parse_many.md describes an interface providing features to work with files or streams containing multiple small JSON documents. As fast and convenient as possible.
|
* parse_many: https://github.com/simdjson/simdjson/blob/master/doc/parse_many.md describes an interface providing features to work with files or streams containing multiple small JSON documents. As fast and convenient as possible.
|
||||||
* Performance: https://github.com/simdjson/simdjson/blob/master/doc/performance.md shows some more advanced scenarios and how to tune for them.
|
* Performance: https://github.com/simdjson/simdjson/blob/master/doc/performance.md shows some more advanced scenarios and how to tune for them.
|
||||||
|
|||||||
+17
-7
@@ -3,8 +3,8 @@ The Document-Object-Model (DOM) front-end
|
|||||||
|
|
||||||
An overview of what you need to know to use simdjson, with examples.
|
An overview of what you need to know to use simdjson, with examples.
|
||||||
|
|
||||||
* [DOM vs On Demand](#dom-vs-ondemand)
|
* [DOM vs On Demand](#dom-vs-on-demand)
|
||||||
* [The Basics: Loading and Parsing JSON Documents](#the-basics-loading-and-parsing-json-documents)
|
* [The Basics: Loading and Parsing JSON Documents](#the-basics-loading-and-parsing-json-documents-using-the-dom-front-end)
|
||||||
* [Using the Parsed JSON](#using-the-parsed-json)
|
* [Using the Parsed JSON](#using-the-parsed-json)
|
||||||
* [C++17 Support](#c17-support)
|
* [C++17 Support](#c17-support)
|
||||||
* [JSON Pointer](#json-pointer)
|
* [JSON Pointer](#json-pointer)
|
||||||
@@ -64,7 +64,7 @@ Once you have an element, you can navigate it with idiomatic C++ iterators, oper
|
|||||||
|
|
||||||
* **Extracting Values (with exceptions):** You can cast a JSON element to a native type: `double(element)` or
|
* **Extracting Values (with exceptions):** You can cast a JSON element to a native type: `double(element)` or
|
||||||
`double x = json_element`. This works for double, uint64_t, int64_t, bool,
|
`double x = json_element`. This works for double, uint64_t, int64_t, bool,
|
||||||
dom::object and dom::array. An exception is thrown if the cast is not possible.
|
dom::object and dom::array. An exception (`simdjson::simdjson_error`) is thrown if the cast is not possible.
|
||||||
* **Extracting Values (without exceptions):** You can use a variant usage of `get()` with error codes to avoid exceptions. You first declare the variable of the appropriate type (`double`, `uint64_t`, `int64_t`, `bool`,
|
* **Extracting Values (without exceptions):** You can use a variant usage of `get()` with error codes to avoid exceptions. You first declare the variable of the appropriate type (`double`, `uint64_t`, `int64_t`, `bool`,
|
||||||
`dom::object` and `dom::array`) and pass it by reference to `get()` which gives you back an error code: e.g.,
|
`dom::object` and `dom::array`) and pass it by reference to `get()` which gives you back an error code: e.g.,
|
||||||
```c++
|
```c++
|
||||||
@@ -81,7 +81,7 @@ Once you have an element, you can navigate it with idiomatic C++ iterators, oper
|
|||||||
know the type of the value, you can cast it right there, too! `for (double value : array) { ... }`
|
know the type of the value, you can cast it right there, too! `for (double value : array) { ... }`
|
||||||
* **Object Iteration:** You can iterate through an object's fields, too: `for (auto [key, value] : object)`
|
* **Object Iteration:** You can iterate through an object's fields, too: `for (auto [key, value] : object)`
|
||||||
* **Array Index:** To get at an array value by index, use the at() method: `array.at(0)` gets the
|
* **Array Index:** To get at an array value by index, use the at() method: `array.at(0)` gets the
|
||||||
first element.
|
first element. The at() method has linear-time complexity so it should not be used to iterate over the values of an array.
|
||||||
> Note that array[0] does not compile, because implementing [] gives the impression indexing is a
|
> Note that array[0] does not compile, because implementing [] gives the impression indexing is a
|
||||||
> O(1) operation, which it is not presently in simdjson. Instead, you should iterate over the elements
|
> O(1) operation, which it is not presently in simdjson. Instead, you should iterate over the elements
|
||||||
> using a for-loop, as in our examples.
|
> using a for-loop, as in our examples.
|
||||||
@@ -89,7 +89,7 @@ Once you have an element, you can navigate it with idiomatic C++ iterators, oper
|
|||||||
with the `size()` method.
|
with the `size()` method.
|
||||||
* **Checking an Element Type:** You can check an element's type with `element.type()`. It
|
* **Checking an Element Type:** You can check an element's type with `element.type()`. It
|
||||||
returns an `element_type` with values such as `simdjson::dom::element_type::ARRAY`, `simdjson::dom::element_type::OBJECT`, `simdjson::dom::element_type::INT64`, `simdjson::dom::element_type::UINT64`,`simdjson::dom::element_type::DOUBLE`, `simdjson::dom::element_type::BOOL` or, `simdjson::dom::element_type::NULL_VALUE`.
|
returns an `element_type` with values such as `simdjson::dom::element_type::ARRAY`, `simdjson::dom::element_type::OBJECT`, `simdjson::dom::element_type::INT64`, `simdjson::dom::element_type::UINT64`,`simdjson::dom::element_type::DOUBLE`, `simdjson::dom::element_type::BOOL` or, `simdjson::dom::element_type::NULL_VALUE`.
|
||||||
* **Output to streams and strings:** Given a document or an element (or node) out of a JSON document, you can output a minified string version using the C++ stream idiom (`out << element`). You can also request the construction of a minified string version (`simdjson::minify(element)`).
|
* **Output to streams and strings:** Given a document or an element (or node) out of a JSON document, you can output a minified string version using the C++ stream idiom (`out << element`). You can also request the construction of a minified string version (`simdjson::minify(element)`). Numbers are serialized as 64-bit floating-point numbers (`double`).
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ select the value. If your keys contain the characters '/' or '~', they must be e
|
|||||||
'~0' respectively. An empty JSON Path refers to the whole document.
|
'~0' respectively. An empty JSON Path refers to the whole document.
|
||||||
|
|
||||||
We also extend the JSON Pointer support to include *relative* paths.
|
We also extend the JSON Pointer support to include *relative* paths.
|
||||||
You can apply a JSON path to any node and the path gets interpreted relatively, as if the currrent node were a whole JSON document.
|
You can apply a JSON path to any node and the path gets interpreted relatively, as if the current node were a whole JSON document.
|
||||||
|
|
||||||
Consider the following example:
|
Consider the following example:
|
||||||
|
|
||||||
@@ -249,7 +249,11 @@ auto error = parser.parse(json).get(doc);
|
|||||||
if (error) { cerr << error << endl; exit(1); }
|
if (error) { cerr << error << endl; exit(1); }
|
||||||
```
|
```
|
||||||
|
|
||||||
When you use the code this way, it is your responsibility to check for error before using the
|
When there is no error, the error code simdjson::SUCCESS is returned: it evaluates as false as a Boolean.
|
||||||
|
We have several error codes to indicate errors, they all evaluate to true as a Boolean: your software should not generally not depend on exact
|
||||||
|
error codes. We may change the error codes in future releases and the exact error codes could vary depending on your system.
|
||||||
|
|
||||||
|
When you use the code without exceptions, it is your responsibility to check for error before using the
|
||||||
result: if there is an error, the result value will not be valid and using it will caused undefined
|
result: if there is an error, the result value will not be valid and using it will caused undefined
|
||||||
behavior.
|
behavior.
|
||||||
|
|
||||||
@@ -274,6 +278,7 @@ Our program loads the file, selects value corresponding to key "search_metadata"
|
|||||||
it selects the key "count" within that object.
|
it selects the key "count" within that object.
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
|
#include <iostream>
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
@@ -301,6 +306,7 @@ triggering exceptions. To do this, we use `["statuses"].at(0)["id"]`. We break t
|
|||||||
Observe how we use the `at` method when querying an index into an array, and not the bracket operator.
|
Observe how we use the `at` method when querying an index into an array, and not the bracket operator.
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
|
#include <iostream>
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
@@ -316,6 +322,9 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `at()` method has linear-time complexity: it should not be used to iterate
|
||||||
|
over the content of an array.
|
||||||
|
|
||||||
### Error Handling Example
|
### Error Handling Example
|
||||||
|
|
||||||
This is how the example in "Using the Parsed JSON" could be written using only error code checking:
|
This is how the example in "Using the Parsed JSON" could be written using only error code checking:
|
||||||
@@ -457,6 +466,7 @@ program from continuing if there was an error.
|
|||||||
If one is willing to trigger exceptions, it is possible to write simpler code:
|
If one is willing to trigger exceptions, it is possible to write simpler code:
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
|
#include <iostream>
|
||||||
#include "simdjson.h"
|
#include "simdjson.h"
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|||||||
@@ -50,9 +50,9 @@ Inspecting the Detected Implementation
|
|||||||
You can check what implementation is running with `active_implementation`:
|
You can check what implementation is running with `active_implementation`:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
cout << "simdjson v" << STRINGIFY(SIMDJSON_VERSION) << endl;
|
cout << "simdjson v" << SIMDJSON_STRINGIFY(SIMDJSON_VERSION) << endl;
|
||||||
cout << "Detected the best implementation for your machine: " << simdjson::active_implementation->name();
|
cout << "Detected the best implementation for your machine: " << simdjson::get_active_implementation()->name();
|
||||||
cout << "(" << simdjson::active_implementation->description() << ")" << endl;
|
cout << "(" << simdjson::get_active_implementation()->description() << ")" << endl;
|
||||||
```
|
```
|
||||||
|
|
||||||
Implementation detection will happen in this case when you first call `name()`.
|
Implementation detection will happen in this case when you first call `name()`.
|
||||||
@@ -63,7 +63,7 @@ Querying Available Implementations
|
|||||||
You can list all available implementations, regardless of which one was selected:
|
You can list all available implementations, regardless of which one was selected:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
for (auto implementation : simdjson::available_implementations) {
|
for (auto implementation : simdjson::get_available_implementations()) {
|
||||||
cout << implementation->name() << ": " << implementation->description() << endl;
|
cout << implementation->name() << ": " << implementation->description() << endl;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -71,10 +71,10 @@ for (auto implementation : simdjson::available_implementations) {
|
|||||||
And look them up by name:
|
And look them up by name:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
cout << simdjson::available_implementations["fallback"]->description() << endl;
|
cout << simdjson::get_available_implementations()["fallback"]->description() << endl;
|
||||||
```
|
```
|
||||||
Though the fallback implementation should always be available, others might be missing. When
|
Though the fallback implementation should always be available, others might be missing. When
|
||||||
an implementation is not available, the bracket call `simdjson::available_implementations[name]`
|
an implementation is not available, the bracket call `simdjson::get_available_implementations()[name]`
|
||||||
will return the null pointer.
|
will return the null pointer.
|
||||||
|
|
||||||
The available implementations have been compiled but may not necessarily be run safely on your system
|
The available implementations have been compiled but may not necessarily be run safely on your system
|
||||||
@@ -90,18 +90,18 @@ can select the CPU architecture yourself:
|
|||||||
|
|
||||||
```c++
|
```c++
|
||||||
// Use the fallback implementation, even though my machine is fast enough for anything
|
// Use the fallback implementation, even though my machine is fast enough for anything
|
||||||
simdjson::active_implementation = simdjson::available_implementations["fallback"];
|
simdjson::get_active_implementation() = simdjson::get_available_implementations()["fallback"];
|
||||||
```
|
```
|
||||||
|
|
||||||
You are responsible for ensuring that the requirements of the selected implementation match your current system.
|
You are responsible for ensuring that the requirements of the selected implementation match your current system.
|
||||||
Furthermore, you should check that the implementation is available before setting it to `simdjson::active_implementation`
|
Furthermore, you should check that the implementation is available before setting it to `simdjson::get_active_implementation()`
|
||||||
by comparing it with the null pointer.
|
by comparing it with the null pointer.
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
auto my_implementation = simdjson::available_implementations["haswell"];
|
auto my_implementation = simdjson::get_available_implementations()["haswell"];
|
||||||
if(! my_implementation) { exit(1); }
|
if(! my_implementation) { exit(1); }
|
||||||
if(! my_implementation->supported_by_runtime_system()) { exit(1); }
|
if(! my_implementation->supported_by_runtime_system()) { exit(1); }
|
||||||
simdjson::active_implementation = my_implementation;
|
simdjson::get_active_implementation() = my_implementation;
|
||||||
```
|
```
|
||||||
|
|
||||||
Checking that an Implementation can Run on your System
|
Checking that an Implementation can Run on your System
|
||||||
@@ -110,12 +110,12 @@ Checking that an Implementation can Run on your System
|
|||||||
You should call `supported_by_runtime_system()` to compare the processor's features with the need of the implementation.
|
You should call `supported_by_runtime_system()` to compare the processor's features with the need of the implementation.
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
for (auto implementation : simdjson::available_implementations) {
|
for (auto implementation : simdjson::get_available_implementations()) {
|
||||||
if(implementation->supported_by_runtime_system()) {
|
if(implementation->supported_by_runtime_system()) {
|
||||||
cout << implementation->name() << ": " << implementation->description() << endl;
|
cout << implementation->name() << ": " << implementation->description() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The call to `supported_by_runtime_system()` maybe relatively expensive. Do not call `supported_by_runtime_system()` each
|
The call to `supported_by_runtime_system()` may be relatively expensive. Do not call `supported_by_runtime_system()` each
|
||||||
time you parse a JSON input (for example). It is meant to be called a handful of times at most in the life of a program.
|
time you parse a JSON input (for example). It is meant to be called a handful of times at most in the life of a program.
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user