Skip to content

Commit fc50a36

Browse files
committed
Make checkperf build master with the same options
1 parent 9bf9fba commit fc50a36

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ libs
5353
objs
5454

5555
# Build outputs (TODO build to a subdir so we can exclude that instead)
56+
/.simdjson-user-CMakeCache.txt
5657
/allparserscheckfile
5758
/allparsingcompetition
5859
/basictests
@@ -124,10 +125,10 @@ objs
124125
/stringparsingcheck
125126
/submodules
126127
/ujdecode.o
127-
/amalgamation_demo.cpp
128+
/amalgamate_demo.cpp
128129
/simdjson.cpp
129130
/simdjson.h
130-
/singleheader/amalgamation_demo
131+
/singleheader/amalgamate_demo
131132
/singleheader/demo
132133
/tests/allparserscheckfile
133134
/tests/basictests

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ set(PROJECT_VERSION_MINOR 3)
1717
set(PROJECT_VERSION_PATCH 1)
1818
set(SIMDJSON_LIB_VERSION "0.3.1" CACHE STRING "simdjson library version")
1919
set(SIMDJSON_LIB_SOVERSION "1" CACHE STRING "simdjson library soversion")
20+
set(SIMDJSON_GITHUB_REPOSITORY https://github.com/simdjson/simdjson)
2021

2122
if(MSVC)
2223
option(SIMDJSON_BUILD_STATIC "Build a static library" ON) # turning it on disables the production of a dynamic library
@@ -120,6 +121,23 @@ endfunction()
120121

121122
export_private_library(simdjson-flags)
122123

124+
#
125+
# ${SIMDJSON_USER_CMAKECACHE} contains the *user-specified* simdjson options so you can call cmake on
126+
# another branch or repository with the same options.
127+
#
128+
# Not supported on Windows at present, because the only thing that uses it is checkperf, which we
129+
# don't run on Windows.
130+
#
131+
if (NOT MSVC)
132+
set(SIMDJSON_USER_CMAKECACHE ${CMAKE_CURRENT_BINARY_DIR}/.simdjson-user-CMakeCache.txt)
133+
add_custom_command(
134+
OUTPUT ${SIMDJSON_USER_CMAKECACHE}
135+
COMMAND bash -c "grep SIMDJSON_ ${PROJECT_BINARY_DIR}/CMakeCache.txt | grep -v SIMDJSON_LIB_ > ${SIMDJSON_USER_CMAKECACHE}"
136+
VERBATIM # Makes it not do weird escaping with the command
137+
)
138+
add_custom_target(simdjson-user-cmakecache ALL DEPENDS ${SIMDJSON_USER_CMAKECACHE})
139+
endif()
140+
123141
#
124142
# Create the top level simdjson library (must be done at this level to use both src/ and include/
125143
# directories) and tools

benchmark/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ if (NOT MSVC)
4141
CHECKPERF_REPOSITORY=https://github.com/simdjson/simdjson
4242
CHECKPERF_BRANCH=master
4343
CHECKPERF_DIR=${CMAKE_CURRENT_BINARY_DIR}/simdjson-master
44+
CHECKPERF_CMAKECACHE=${SIMDJSON_USER_CMAKECACHE}
4445
bash ${CMAKE_CURRENT_SOURCE_DIR}/checkperf.sh ${PROJECT_SOURCE_DIR}/jsonexamples/twitter.json)
45-
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff)
46-
endif()
46+
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE})
47+
endif()

benchmark/checkperf.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -ex
44

5+
set | grep CHECKPERF
6+
57
if [ -z "$CHECKPERF_REPOSITORY" ]; then CHECKPERF_REPOSITORY=.; fi
68

79
# Arguments: perfdiff.sh <branch> <test json files>
@@ -29,10 +31,18 @@ else
2931
fi
3032

3133
echo "Building $CHECKPERF_DIR/parse ..."
32-
make parse
34+
if [ -n "$CHECKPERF_CMAKECACHE" ]; then
35+
cp $CHECKPERF_CMAKECACHE $CHECKPERF_DIR/CMakeCache.txt
36+
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_COMPETITION=OFF .
37+
make parse
38+
REFERENCE_PARSE=$CHECKPERF_DIR/benchmark/parse
39+
else
40+
make parse
41+
REFERENCE_PARSE=$CHECKPERF_DIR/parse
42+
fi
3343
popd
3444

3545
# Run them and diff performance
3646
echo "Running perfdiff:"
37-
echo ./perfdiff \"./parse -t $CHECKPERF_ARGS\" \"$CHECKPERF_DIR/parse -t $CHECKPERF_ARGS\"
38-
./perfdiff "./parse -t $CHECKPERF_ARGS" "$CHECKPERF_DIR/parse -t $CHECKPERF_ARGS"
47+
echo ./perfdiff \"./parse -t $CHECKPERF_ARGS\" \"$REFERENCE_PARSE -t $CHECKPERF_ARGS\"
48+
./perfdiff "./parse -t $CHECKPERF_ARGS" "$REFERENCE_PARSE -t $CHECKPERF_ARGS"

0 commit comments

Comments
 (0)