diff --git a/CHANGELOG.md b/CHANGELOG.md index b086e768..1944affb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Version 91: * Use fopen_s on Windows * Fix Appveyor script * Update project metadata +* Move benchmarks to bench/ WebSocket: diff --git a/CMakeLists.txt b/CMakeLists.txt index c7966e3f..5f40dd8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ cmake_minimum_required (VERSION 3.5.2) project (Beast VERSION 90) set_property (GLOBAL PROPERTY USE_FOLDERS ON) +option (Beast_BUILD_BENCH "Build bench" ON) option (Beast_BUILD_EXAMPLES "Build examples" ON) option (Beast_BUILD_TESTS "Build tests" ON) @@ -189,8 +190,8 @@ file(GLOB_RECURSE EXTRAS_INCLUDES ${PROJECT_SOURCE_DIR}/extras/boost/beast/*.ipp ) -if (Beast_BUILD_TESTS) - add_subdirectory (test) +if (Beast_BUILD_BENCH) + add_subdirectory (bench) endif() if (Beast_BUILD_EXAMPLES AND @@ -198,3 +199,7 @@ if (Beast_BUILD_EXAMPLES AND (NOT "${VARIANT}" STREQUAL "ubasan")) add_subdirectory (example) endif() + +if (Beast_BUILD_TESTS) + add_subdirectory (test) +endif() diff --git a/Jamfile b/Jamfile index faef758d..a54ea8ce 100644 --- a/Jamfile +++ b/Jamfile @@ -19,36 +19,36 @@ boost.use-project ; if [ os.name ] = SOLARIS { - lib socket ; - lib nsl ; + lib socket ; + lib nsl ; } else if [ os.name ] = NT { - lib ws2_32 ; - lib mswsock ; + lib ws2_32 ; + lib mswsock ; } else if [ os.name ] = HPUX { - lib ipv6 ; + lib ipv6 ; } else if [ os.name ] = QNXNTO { - lib socket ; + lib socket ; } else if [ os.name ] = HAIKU { - lib network ; + lib network ; } if [ os.name ] = NT { - lib ssl : : ssleay32 ; - lib crypto : : libeay32 ; + lib ssl : : ssleay32 ; + lib crypto : : libeay32 ; } else { - lib ssl ; - lib crypto ; + lib ssl ; + lib crypto ; } variant coverage : @@ -59,16 +59,18 @@ variant coverage : ; variant ubasan - : + : release - : + : "-msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=libs/beast/scripts/blacklist.supp" "-fsanitize=address,undefined" - ; + ; #cxx11_hdr_type_traits local REQ = [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_decltype cxx11_hdr_tuple ] ; +path-constant TEST_MAIN : extras/boost/beast/unit_test/main.cpp ; + project beast : requirements #$(REQ) @@ -79,6 +81,7 @@ project beast /boost/system//boost_system /boost/coroutine//boost_coroutine/BOOST_COROUTINES_NO_DEPRECATION_WARNING=1 /boost/filesystem//boost_filesystem + static BOOST_ALL_NO_LIB=1 BOOST_COROUTINES_NO_DEPRECATION_WARNING=1 multi diff --git a/README.md b/README.md index 44c7f200..e1e5b8f7 100644 --- a/README.md +++ b/README.md @@ -110,14 +110,16 @@ The files in the repository are laid out thusly: ``` ./ + bench/ Benchmarking programs bin/ Create this to hold executables and project files bin64/ Create this to hold 64-bit Windows executables and project files doc/ Source code and scripts for the documentation - include/ Add this to your compiler includes - beast/ + include/ Where the header files live extras/ Additional APIs, may change example/ Self contained example programs - test/ Unit tests and benchmarks + meta/ Metadata for Boost integration + scripts/ Small scripts used with CI systems + test/ Unit tests ``` ## Usage diff --git a/test/benchmarks/CMakeLists.txt b/bench/CMakeLists.txt similarity index 85% rename from test/benchmarks/CMakeLists.txt rename to bench/CMakeLists.txt index 0e6a3e1c..f5a44e2a 100644 --- a/test/benchmarks/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -16,11 +16,13 @@ add_executable (benchmarks ${BOOST_BEAST_INCLUDES} ${EXTRAS_INCLUDES} Jamfile - ../../extras/boost/beast/unit_test/main.cpp - ../http/message_fuzz.hpp + ../extras/boost/beast/unit_test/main.cpp + ../test/http/message_fuzz.hpp nodejs_parser.hpp - buffers.cpp nodejs_parser.cpp + buffers.cpp parser.cpp utf8_checker.cpp ) + +add_subdirectory (wstest) diff --git a/test/benchmarks/Jamfile b/bench/Jamfile similarity index 54% rename from test/benchmarks/Jamfile rename to bench/Jamfile index 579745e8..8d36edcb 100644 --- a/test/benchmarks/Jamfile +++ b/bench/Jamfile @@ -9,13 +9,14 @@ local SOURCES = buffers.cpp - nodejs_parser.cpp - parser.cpp - #utf8_checker.cpp # causes unnecessary dependencies + utf8_checker.cpp # causes unnecessary dependencies ; -unit-test run-fat : $(TEST_MAIN) $(SOURCES) : : : coverage:no ubasan:no ; -explicit run-fat ; +local BUILD_BENCH ; for local f in $(SOURCES) { BUILD_BENCH += [ exe $(f:B)-bench : $(f) $(TEST_MAIN) ] ; } +alias build-bench : $(BUILD_BENCH) ; -exe build-fat : $(TEST_MAIN) $(SOURCES) : : : coverage:no ubasan:no ; -explicit build-fat ; +exe parser-bench : + nodejs_parser.cpp + parser.cpp + $(TEST_MAIN) + ; diff --git a/test/benchmarks/buffers.cpp b/bench/buffers.cpp similarity index 100% rename from test/benchmarks/buffers.cpp rename to bench/buffers.cpp diff --git a/test/benchmarks/nodejs-parser/AUTHORS b/bench/nodejs-parser/AUTHORS similarity index 100% rename from test/benchmarks/nodejs-parser/AUTHORS rename to bench/nodejs-parser/AUTHORS diff --git a/test/benchmarks/nodejs-parser/LICENSE-MIT b/bench/nodejs-parser/LICENSE-MIT similarity index 100% rename from test/benchmarks/nodejs-parser/LICENSE-MIT rename to bench/nodejs-parser/LICENSE-MIT diff --git a/test/benchmarks/nodejs-parser/README.md b/bench/nodejs-parser/README.md similarity index 100% rename from test/benchmarks/nodejs-parser/README.md rename to bench/nodejs-parser/README.md diff --git a/test/benchmarks/nodejs-parser/http_parser.c b/bench/nodejs-parser/http_parser.c similarity index 100% rename from test/benchmarks/nodejs-parser/http_parser.c rename to bench/nodejs-parser/http_parser.c diff --git a/test/benchmarks/nodejs-parser/http_parser.h b/bench/nodejs-parser/http_parser.h similarity index 100% rename from test/benchmarks/nodejs-parser/http_parser.h rename to bench/nodejs-parser/http_parser.h diff --git a/test/benchmarks/nodejs_parser.cpp b/bench/nodejs_parser.cpp similarity index 100% rename from test/benchmarks/nodejs_parser.cpp rename to bench/nodejs_parser.cpp diff --git a/test/benchmarks/nodejs_parser.hpp b/bench/nodejs_parser.hpp similarity index 100% rename from test/benchmarks/nodejs_parser.hpp rename to bench/nodejs_parser.hpp diff --git a/test/benchmarks/parser.cpp b/bench/parser.cpp similarity index 99% rename from test/benchmarks/parser.cpp rename to bench/parser.cpp index 5bbf097c..7fc5f0ed 100644 --- a/test/benchmarks/parser.cpp +++ b/bench/parser.cpp @@ -8,7 +8,7 @@ // #include "nodejs_parser.hpp" -#include "../http/message_fuzz.hpp" +#include "test/http/message_fuzz.hpp" #include #include diff --git a/test/benchmarks/utf8_checker.cpp b/bench/utf8_checker.cpp similarity index 93% rename from test/benchmarks/utf8_checker.cpp rename to bench/utf8_checker.cpp index cf991d3d..ba958003 100644 --- a/test/benchmarks/utf8_checker.cpp +++ b/bench/utf8_checker.cpp @@ -9,10 +9,17 @@ #include #include -#include #include #include +#ifndef BEAST_USE_BOOST_LOCALE_BENCHMARK +#define BEAST_USE_BOOST_LOCALE_BENCHMARK 0 +#endif + +#if BEAST_USE_BOOST_LOCALE_BENCHMARK +#include +#endif + namespace boost { namespace beast { @@ -79,6 +86,14 @@ public: return s; } + void + checkBeast(std::string const& s) + { + beast::websocket::detail::check_utf8( + s.data(), s.size()); + } + +#if BEAST_USE_BOOST_LOCALE_BENCHMARK void checkLocale(std::string const& s) { @@ -92,13 +107,7 @@ public: break; } } - - void - checkBeast(std::string const& s) - { - beast::websocket::detail::check_utf8( - s.data(), s.size()); - } +#endif template typename timer::clock_type::duration @@ -124,6 +133,7 @@ public: }); log << "beast: " << throughput(elapsed, s.size()) << " char/s" << std::endl; } + #if BEAST_USE_BOOST_LOCALE_BENCHMARK for(int i = 0; i < 5; ++ i) { auto const elapsed = test([&]{ @@ -135,6 +145,7 @@ public: }); log << "locale: " << throughput(elapsed, s.size()) << " char/s" << std::endl; } + #endif pass(); } }; diff --git a/test/wstest/CMakeLists.txt b/bench/wstest/CMakeLists.txt similarity index 94% rename from test/wstest/CMakeLists.txt rename to bench/wstest/CMakeLists.txt index 34f47321..b803852d 100644 --- a/test/wstest/CMakeLists.txt +++ b/bench/wstest/CMakeLists.txt @@ -10,7 +10,7 @@ GroupSources(include/boost/beast beast) GroupSources(example/common common) GroupSources(extras/boost/beast extras) -GroupSources(test/wstest "/") +GroupSources(bench/wstest "/") add_executable (wstest ${BOOST_BEAST_INCLUDES} diff --git a/test/wstest/Jamfile b/bench/wstest/Jamfile similarity index 69% rename from test/wstest/Jamfile rename to bench/wstest/Jamfile index e0594cde..f0a43406 100644 --- a/test/wstest/Jamfile +++ b/bench/wstest/Jamfile @@ -7,9 +7,6 @@ # Official repository: https://github.com/boostorg/beast # -alias wstest : +exe wstest : wstest.cpp ; -explicit wstest ; - -alias run-tests : [ compile wstest.cpp ] : : : coverage:no ubasan:no ; diff --git a/test/wstest/wstest.cpp b/bench/wstest/wstest.cpp similarity index 100% rename from test/wstest/wstest.cpp rename to bench/wstest/wstest.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9dea8831..925d0d1d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,13 +10,11 @@ add_subdirectory (core) add_subdirectory (http) add_subdirectory (websocket) -add_subdirectory (wstest) add_subdirectory (zlib) if ((NOT "${VARIANT}" STREQUAL "coverage") AND (NOT "${VARIANT}" STREQUAL "ubasan")) - add_subdirectory (benchmarks) add_subdirectory (common) add_subdirectory (server) diff --git a/test/Jamfile b/test/Jamfile index bd4e5293..4fdaa1fc 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -9,8 +9,6 @@ import os ; -path-constant TEST_MAIN : ../extras/boost/beast/unit_test/main.cpp ; - compile config.cpp : coverage:no ubasan:no ; compile core.cpp : coverage:no ubasan:no ; compile exemplars.cpp : coverage:no ubasan:no ; @@ -20,36 +18,30 @@ compile websocket.cpp : coverage:no ubasan:no ; compile zlib.cpp : coverage:no ubasan:no ; alias run-tests : - #benchmarks//run-tests # not necessary common//run-tests core//run-tests http//run-tests server//run-tests websocket//run-tests - wstest//run-tests zlib//run-tests ; alias run-fat : - benchmarks//run-fat common//run-fat core//run-fat http//run-fat server//run-fat websocket//run-fat - #wstest//run-fat # not available zlib//run-fat ; explicit run-fat ; alias build-fat : - benchmarks//build-fat common//build-fat core//build-fat http//build-fat server//build-fat websocket//build-fat - #wstest//build-fat # not available zlib//build-fat ; explicit build-fat ;