Skip to content

add generic benchmarking utility, and clean up other benchmarks. Upda… #32

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ install(FILES include/jsonlogic/details/ast-full.hpp DESTINATION "include/jsonlo
if(JSONLOGIC_ENABLE_BENCH)
message(STATUS "Building benchmarks: ${JSONLOGIC_ENABLE_BENCH}")
add_subdirectory(bench)
add_custom_target(bench
DEPENDS jl-bench-eq jl-bench-membership jl-bench-generic
)
endif()
if(JSONLOGIC_ENABLE_TESTS)
message(STATUS "Building tests: ${JSONLOGIC_ENABLE_TESTS}")
Expand Down
17 changes: 14 additions & 3 deletions cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@ The library is designed to follow the type conversion rules of the reference Jso
## Compile and Install

The library can be installed using cmake. From the top-level directory,
cmake --preset=default
cd build/release
make
```
cmake --preset=default
cd build/release
make
```
Benchmarks can be made with
```
make bench
```

Tests can be run with
```
make testeval && make test
```

## Use

Expand Down
35 changes: 21 additions & 14 deletions cpp/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# project(jl-bench-eqs)

# set(CMAKE_BUILD_TYPE Debug)
include(FetchContent)

set(BUILD_TESTING OFF) # Disable Faker tests
FetchContent_Declare(faker
GIT_REPOSITORY https://github.com/cieslarmichal/faker-cxx.git
Expand All @@ -11,6 +13,13 @@ FetchContent_Declare(faker

FetchContent_MakeAvailable(faker)

FetchContent_Declare(
cxxopts
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
GIT_TAG v3.3.1
)
FetchContent_MakeAvailable(cxxopts)

add_executable(jl-bench-eq src/benchmark-equality.cpp)
add_compile_options(-Wall -Wextra -Wunused-variable)

Expand Down Expand Up @@ -64,22 +73,20 @@ target_link_libraries(jl-bench-membership PRIVATE jsonlogic faker-cxx)
# ${CMAKE_BINARY_DIR}/_deps/faker-src/include
# )

add_executable(jl-bench-complex1 src/benchmark-complex1.cpp)
target_compile_options(jl-bench-complex1 PRIVATE -O3)
target_include_directories(jl-bench-complex1 SYSTEM PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../bench/include
${CMAKE_CURRENT_SOURCE_DIR}/../include
)

configure_file(${CMAKE_SOURCE_DIR}/bench/src/complex1.json ${CMAKE_BINARY_DIR}/bench/complex1.json COPYONLY)
target_link_libraries(jl-bench-complex1 PRIVATE jsonlogic faker-cxx)

add_executable(jl-bench-simple-and src/benchmark-simple-and.cpp)
target_compile_options(jl-bench-simple-and PRIVATE -O3)
target_include_directories(jl-bench-simple-and SYSTEM PRIVATE
add_executable(jl-bench-generic src/benchmark-generic.cpp)
target_include_directories(jl-bench-generic SYSTEM PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../bench/include
${CMAKE_CURRENT_SOURCE_DIR}/../include
)

configure_file(${CMAKE_SOURCE_DIR}/bench/src/simple-and.json ${CMAKE_BINARY_DIR}/bench/simple-and.json COPYONLY)
target_link_libraries(jl-bench-simple-and PRIVATE jsonlogic faker-cxx)
target_link_libraries(jl-bench-generic PRIVATE faker-cxx jsonlogic cxxopts)
target_compile_features(jl-bench-generic PRIVATE cxx_std_20)
target_compile_options(jl-bench-generic PRIVATE -O3)

# Copy all .json files from bench/src to the build directory's bench folder
file(GLOB BENCH_JSON_FILES "${CMAKE_SOURCE_DIR}/bench/src/*.json")
foreach(jsonfile ${BENCH_JSON_FILES})
get_filename_component(jsonfile_name "${jsonfile}" NAME)
configure_file(${jsonfile} ${CMAKE_BINARY_DIR}/bench/${jsonfile_name} COPYONLY)
endforeach()
150 changes: 0 additions & 150 deletions cpp/bench/src/benchmark-complex1.cpp

This file was deleted.

Loading