From 9bf9fba2ec691f8f7cc604c300bb7cb726444358 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Thu, 16 Apr 2020 13:49:17 -0700 Subject: [PATCH] Add checkperf to cmake --- .circleci/config.yml | 2 +- .drone.yml | 30 +++++++++++++++--------------- .gitignore | 2 ++ Makefile | 6 +++--- benchmark/CMakeLists.txt | 10 ++++++++++ benchmark/checkperf.sh | 38 ++++++++++++++++++++++++++++++++++++++ scripts/checkperf.sh | 33 --------------------------------- src/CMakeLists.txt | 4 ++-- 8 files changed, 71 insertions(+), 54 deletions(-) create mode 100644 benchmark/checkperf.sh delete mode 100644 scripts/checkperf.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index d84c2d5cd..00f84b0a9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: diff --git a/.drone.yml b/.drone.yml index 35e9f62f4..80eca218f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 diff --git a/.gitignore b/.gitignore index a28285294..6ee7af9f4 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile b/Makefile index bddcf5402..93b72d732 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 93e594847..543a56520 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/benchmark/checkperf.sh b/benchmark/checkperf.sh new file mode 100644 index 000000000..f133c063e --- /dev/null +++ b/benchmark/checkperf.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -ex + +if [ -z "$CHECKPERF_REPOSITORY" ]; then CHECKPERF_REPOSITORY=.; fi + +# Arguments: perfdiff.sh +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" diff --git a/scripts/checkperf.sh b/scripts/checkperf.sh deleted file mode 100644 index 8db885d4b..000000000 --- a/scripts/checkperf.sh +++ /dev/null @@ -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 -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" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8148388f1..88c095e3b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() #