Add checkperf to cmake

This commit is contained in:
John Keiser 2020-04-16 13:49:17 -07:00
parent 121615da70
commit 9bf9fba2ec
8 changed files with 71 additions and 54 deletions

View File

@ -67,7 +67,7 @@ commands:
steps:
- cmake_build
- run: ctest $CTEST_FLAGS -L acceptance
- run: ctest $CTEST_FLAGS -LE acceptance
- run: ctest $CTEST_FLAGS -LE acceptance -E checkperf
cmake_test_all:
steps:

View File

@ -231,7 +231,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: amd64_clang_cmake_no_exceptions
@ -254,7 +254,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: amd64_clang_cmake_static
@ -277,7 +277,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: amd64_gcc_cmake_static
@ -300,7 +300,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: amd64_gcc_cmake_dynamic
@ -323,7 +323,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: arm64_clang_cmake_dynamic
@ -346,7 +346,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: arm64_gcc_cmake_dynamic
@ -369,7 +369,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: arm64_clang_cmake_static
@ -392,7 +392,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: arm64_gcc_cmake_static
@ -415,7 +415,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ctest -j --output-on-failure
- ctest -j --output-on-failure -E checkperf
---
kind: pipeline
@ -439,7 +439,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: arm64_gcc_cmake_sanitize
@ -462,7 +462,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure -E checkperf
---
kind: pipeline
@ -486,7 +486,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: amd64_gcc_cmake_sanitize
@ -509,7 +509,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure -E checkperf
---
kind: pipeline
@ -533,7 +533,7 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure -E checkperf
---
kind: pipeline
name: amd64_gcc_cmake_sanitize_noavx
@ -556,4 +556,4 @@ steps:
- mkdir build && cd build
- cmake $CMAKE_FLAGS ..
- make -j
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure -E checkperf

2
.gitignore vendored
View File

@ -71,6 +71,7 @@ objs
/benchmark/parse_stream
/benchmark/parsingcompetition
/benchmark/perfdiff
/benchmark/simdjson-master
/benchmark/statisticalmodel
/build/
/build-ossfuzz-*/
@ -131,6 +132,7 @@ objs
/tests/allparserscheckfile
/tests/basictests
/tests/checkimplementation
/tests/compilation_failure_tests/example_compiletest_should_compile
/tests/errortests
/tests/extracting_values_example
/tests/integer_tests

View File

@ -1,4 +1,4 @@
REFERENCE_VERSION = master
CHECKPERF_BRANCH = master
.SUFFIXES:
#
@ -207,8 +207,8 @@ benchfeatures: benchmark/benchfeatures.cpp benchmark/event_counter.h benchmark/b
perfdiff: benchmark/perfdiff.cpp
$(CXX) $(CXXFLAGS) -o perfdiff benchmark/perfdiff.cpp $(LIBFILES) $(LIBFLAGS)
checkperf:
bash ./scripts/checkperf.sh $(REFERENCE_VERSION)
checkperf: parse perfdiff
CHECKPERF_BRANCH=$(CHECKPERF_BRANCH) bash ./benchmark/checkperf.sh jsonexamples/twitter.json
statisticalmodel: benchmark/statisticalmodel.cpp $(HEADERS) $(LIBFILES)
$(CXX) $(CXXFLAGS) -o statisticalmodel benchmark/statisticalmodel.cpp $(LIBFILES) $(LIBFLAGS)

View File

@ -34,3 +34,13 @@ if (SIMDJSON_COMPETITION)
target_link_libraries(allparsingcompetition competition-all)
target_compile_definitions(allparsingcompetition PRIVATE ALLPARSER)
endif()
if (NOT MSVC)
add_test(NAME checkperf
COMMAND ${CMAKE_COMMAND} -E env
CHECKPERF_REPOSITORY=https://github.com/simdjson/simdjson
CHECKPERF_BRANCH=master
CHECKPERF_DIR=${CMAKE_CURRENT_BINARY_DIR}/simdjson-master
bash ${CMAKE_CURRENT_SOURCE_DIR}/checkperf.sh ${PROJECT_SOURCE_DIR}/jsonexamples/twitter.json)
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff)
endif()

38
benchmark/checkperf.sh Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
set -ex
if [ -z "$CHECKPERF_REPOSITORY" ]; then CHECKPERF_REPOSITORY=.; fi
# Arguments: perfdiff.sh <branch> <test json files>
if [ -z "$CHECKPERF_BRANCH" ]; then CHECKPERF_BRANCH=master; fi
if [ -z "$CHECKPERF_DIR" ]; then CHECKPERF_DIR=benchbranch/$CHECKPERF_BRANCH; fi
if [ -z "$CHECKPERF_ARGS" ]; then
if [ -z "$*" ]; then
CHECKPERF_ARGS=jsonexamples/twitter.json;
else
CHECKPERF_ARGS=$*;
fi
fi
# Clone and build the reference branch's parse
if [ -d $CHECKPERF_DIR/.git ]; then
echo "Checking out the reference branch ($CHECKPERF_BRANCH) into $CHECKPERF_DIR ..."
pushd $CHECKPERF_DIR
git remote update
git reset --hard origin/$CHECKPERF_BRANCH
else
echo "Cloning the reference branch ($CHECKPERF_BRANCH) into $CHECKPERF_DIR ..."
mkdir -p $CHECKPERF_DIR
git clone --depth 1 -b $CHECKPERF_BRANCH $CHECKPERF_REPOSITORY $CHECKPERF_DIR
pushd $CHECKPERF_DIR
fi
echo "Building $CHECKPERF_DIR/parse ..."
make parse
popd
# Run them and diff performance
echo "Running perfdiff:"
echo ./perfdiff \"./parse -t $CHECKPERF_ARGS\" \"$CHECKPERF_DIR/parse -t $CHECKPERF_ARGS\"
./perfdiff "./parse -t $CHECKPERF_ARGS" "$CHECKPERF_DIR/parse -t $CHECKPERF_ARGS"

View File

@ -1,33 +0,0 @@
#!/bin/bash
set -e
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
if [ -z "$CHECKPERF_REPOSITORY" ]; then CHECKPERF_REPOSITORY=.; fi
# Arguments: perfdiff.sh <branch> <test json files>
if [ -z "$1" ]; then reference_branch="master"; else reference_branch=$1; shift; fi
if [ -z "$*" ]; then perftests="jsonexamples/twitter.json"; else perftests=$*; fi
# Clone and build the reference branch's parse
echo "Cloning and build the reference branch ($reference_branch) ..."
current=$SCRIPTPATH/..
reference=$current/benchbranch/$reference_branch
rm -rf $reference
mkdir -p $reference
git clone --depth 1 -b $reference_branch $CHECKPERF_REPOSITORY $reference
cd $reference
make parse
# Build the current branch's parse
echo "Building the current branch ..."
cd $current
make clean
make parse
# Run them and diff performance
make perfdiff
echo "Running perfdiff:"
echo ./perfdiff \"$current/parse -t $perftests $CHECKPERF_ARGS\" \"$reference/parse -t $perftests $CHECKPERF_ARGS\"
./perfdiff "$current/parse -t $perftests $CHECKPERF_ARGS" "$reference/parse -t $perftests $CHECKPERF_ARGS"

View File

@ -49,8 +49,8 @@ target_link_libraries(simdjson PRIVATE simdjson-source simdjson-flags)
if(NOT MSVC)
## We output the library at the root of the current directory where cmake is invoked
## This is handy but Visual Studio will happily ignore us
set_target_properties(simdjson PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
MESSAGE( STATUS "Library output directory (does not apply to Visual Studio): " ${CMAKE_BINARY_DIR})
set_target_properties(simdjson PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
MESSAGE( STATUS "Library output directory (does not apply to Visual Studio): " ${PROJECT_BINARY_DIR})
endif()
#