From 9585e08365b9a27e0e0e30a6c2c88b415af5feef Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 7 Feb 2021 20:15:37 +0100 Subject: [PATCH] CMake: Add benchmarks Put each benchmark application in a sub-directory instead of specifying all in one file, because cotire cannot create PCH targets for the same file twice (bench.cpp). --- build/cmake/benchmarks/CMakeLists.txt | 12 +++++++ build/cmake/benchmarks/bench/CMakeLists.txt | 34 +++++++++++++++++++ .../benchmarks/bench_graphics/CMakeLists.txt | 18 ++++++++++ .../cmake/benchmarks/bench_gui/CMakeLists.txt | 24 +++++++++++++ build/cmake/functions.cmake | 11 ++++-- build/cmake/main.cmake | 4 +++ build/cmake/options.cmake | 1 + 7 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 build/cmake/benchmarks/CMakeLists.txt create mode 100644 build/cmake/benchmarks/bench/CMakeLists.txt create mode 100644 build/cmake/benchmarks/bench_graphics/CMakeLists.txt create mode 100644 build/cmake/benchmarks/bench_gui/CMakeLists.txt diff --git a/build/cmake/benchmarks/CMakeLists.txt b/build/cmake/benchmarks/CMakeLists.txt new file mode 100644 index 0000000000..88d9574af7 --- /dev/null +++ b/build/cmake/benchmarks/CMakeLists.txt @@ -0,0 +1,12 @@ +############################################################################# +# Name: build/cmake/benchmarks/CMakeLists.txt +# Purpose: CMake file for benchmarks +# Author: Maarten Bent +# Created: 2021-02-07 +# Copyright: (c) 2021 wxWidgets development team +# Licence: wxWindows licence +############################################################################# + +add_subdirectory(bench) +add_subdirectory(bench_graphics) +add_subdirectory(bench_gui) diff --git a/build/cmake/benchmarks/bench/CMakeLists.txt b/build/cmake/benchmarks/bench/CMakeLists.txt new file mode 100644 index 0000000000..09e50edaba --- /dev/null +++ b/build/cmake/benchmarks/bench/CMakeLists.txt @@ -0,0 +1,34 @@ +############################################################################# +# Name: build/cmake/benchmarks/bench/CMakeLists.txt +# Purpose: CMake file for benchmarks +# Author: Maarten Bent +# Created: 2021-02-07 +# Copyright: (c) 2021 wxWidgets development team +# Licence: wxWindows licence +############################################################################# + +set(BENCH_SRC + bench.cpp + bench.h + datetime.cpp + htmlparser/htmlpars.cpp + htmlparser/htmlpars.h + htmlparser/htmltag.cpp + htmlparser/htmltag.h + ipcclient.cpp + log.cpp + mbconv.cpp + printfbench.cpp + strings.cpp + tls.cpp + ) + +set(BENCH_DATA + htmltest.html + ) + +wx_add_benchmark(bench CONSOLE ${BENCH_SRC} DATA ${BENCH_DATA}) + +if(wxUSE_SOCKETS) + wx_exe_link_libraries(bench wxnet) +endif() diff --git a/build/cmake/benchmarks/bench_graphics/CMakeLists.txt b/build/cmake/benchmarks/bench_graphics/CMakeLists.txt new file mode 100644 index 0000000000..b8609959ee --- /dev/null +++ b/build/cmake/benchmarks/bench_graphics/CMakeLists.txt @@ -0,0 +1,18 @@ +############################################################################# +# Name: build/cmake/benchmarks/bench_graphics/CMakeLists.txt +# Purpose: CMake file for benchmarks +# Author: Maarten Bent +# Created: 2021-02-07 +# Copyright: (c) 2021 wxWidgets development team +# Licence: wxWindows licence +############################################################################# + +set(BENCH_GRAPGICS_SRC + graphics.cpp + ) + +wx_add_benchmark(bench_graphics CONSOLE_GUI ${BENCH_GRAPGICS_SRC}) + +if(wxUSE_OPENGL) + wx_exe_link_libraries(bench_graphics wxgl) +endif() diff --git a/build/cmake/benchmarks/bench_gui/CMakeLists.txt b/build/cmake/benchmarks/bench_gui/CMakeLists.txt new file mode 100644 index 0000000000..b7cf55ee57 --- /dev/null +++ b/build/cmake/benchmarks/bench_gui/CMakeLists.txt @@ -0,0 +1,24 @@ +############################################################################# +# Name: build/cmake/benchmarks/bench_gui/CMakeLists.txt +# Purpose: CMake file for benchmarks +# Author: Maarten Bent +# Created: 2021-02-07 +# Copyright: (c) 2021 wxWidgets development team +# Licence: wxWindows licence +############################################################################# + +set(BENCH_GUI_SRC + bench.cpp + bench.h + display.cpp + image.cpp + ) + +set(IMAGE_DATA + ../../samples/image/horse.bmp:horse.bmp + ../../samples/image/horse.jpg:horse.jpg + ../../samples/image/horse.png:horse.png + ../../samples/image/horse.tif:horse.tif + ) + +wx_add_benchmark(bench_gui CONSOLE_GUI ${BENCH_GUI_SRC} DATA ${IMAGE_DATA}) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 39e8112a62..1b36e402d0 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -605,12 +605,12 @@ function(wx_print_thirdparty_library_summary) message(STATUS ${message}) endfunction() -# Add sample, test or demo +# Add sample, test, demo or benchmark # wx_add( [CONSOLE|CONSOLE_GUI|DLL] [IMPORTANT] [SRC_FILES...] # [LIBRARIES ...] [NAME target_name] [FOLDER folder] # [DATA ...] [DEFINITIONS ...] [RES ...]) # name default target name -# group can be Samples, Tests or Demos +# group can be Samples, Tests, Demos or Benchmarks # first parameter may be CONSOLE to indicate a console application or DLL to indicate a shared library # or CONSOLE_GUI to indicate a console application that uses gui libraries # all following parameters are src files for the executable @@ -640,6 +640,10 @@ function(wx_add_demo name) wx_add(${name} "Demos" ${ARGN}) endfunction() +function(wx_add_benchmark name) + wx_add(${name} "Benchmarks" ${ARGN}) +endfunction() + function(wx_add name group) cmake_parse_arguments(APP "CONSOLE;CONSOLE_GUI;DLL;IMPORTANT" @@ -669,6 +673,9 @@ function(wx_add name group) elseif(group STREQUAL Demos) set(SUB_DIR "demos/${name}") set(DEFAULT_RC_FILE "demos/${name}/${target_name}.rc") + elseif(group STREQUAL Benchmarks) + set(SUB_DIR "tests/benchmarks") + set(DEFAULT_RC_FILE "samples/sample.rc") else() message(WARNING "Unkown group \"${group}\"") return() diff --git a/build/cmake/main.cmake b/build/cmake/main.cmake index c038bbb387..5707352874 100644 --- a/build/cmake/main.cmake +++ b/build/cmake/main.cmake @@ -32,6 +32,10 @@ if(wxBUILD_DEMOS) add_subdirectory(build/cmake/demos demos) endif() +if(wxBUILD_BENCHMARKS) + add_subdirectory(build/cmake/benchmarks benchmarks) +endif() + if(NOT wxBUILD_CUSTOM_SETUP_HEADER_PATH) # Write setup.h after all variables are available include(build/cmake/setup.cmake) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 2a88f8c24e..a29d646be2 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -15,6 +15,7 @@ wx_option(wxBUILD_SAMPLES "Build only important samples (SOME) or ALL" OFF wx_option(wxBUILD_TESTS "Build console tests (CONSOLE_ONLY) or ALL" OFF STRINGS CONSOLE_ONLY ALL OFF) wx_option(wxBUILD_DEMOS "Build demos" OFF) +wx_option(wxBUILD_BENCHMARKS "Build benchmarks" OFF) wx_option(wxBUILD_PRECOMP "Use precompiled headers") wx_option(wxBUILD_INSTALL "Create install/uninstall target for wxWidgets") wx_option(wxBUILD_COMPATIBILITY