You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/11/19 20:14:25 UTC

[arrow] branch master updated: ARROW-3836: [C++] Add PREFIX, EXTRA_LINK_LIBS, DEPENDENCIES to ADD_ARROW_BENCHMARK

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 9de2edc  ARROW-3836: [C++] Add PREFIX, EXTRA_LINK_LIBS, DEPENDENCIES to ADD_ARROW_BENCHMARK
9de2edc is described below

commit 9de2edcc80b5f0f566d5d5ee731c1665c742b76d
Author: Wes McKinney <we...@apache.org>
AuthorDate: Mon Nov 19 15:14:17 2018 -0500

    ARROW-3836: [C++] Add PREFIX, EXTRA_LINK_LIBS, DEPENDENCIES to ADD_ARROW_BENCHMARK
    
    Also removed some of the functions we had that were working around our lack of these arguments
    
    Author: Wes McKinney <we...@apache.org>
    
    Closes #2993 from wesm/ARROW-3836 and squashes the following commits:
    
    e0972a212 <Wes McKinney> Remove unneeded if statement
    c2f080777 <Wes McKinney> Add PREFIX, EXTRA_LINK_LIBS, DEPENDENCIES to ADD_ARROW_BENCHMARK, simplify existing code
---
 cpp/cmake_modules/BuildUtils.cmake                 | 48 +++++++++++-----------
 cpp/src/parquet/CMakeLists.txt                     | 24 +++++------
 cpp/src/parquet/arrow/CMakeLists.txt               |  8 ++--
 ...ter-benchmark.cc => reader-writer-benchmark.cc} |  0
 4 files changed, 37 insertions(+), 43 deletions(-)

diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake
index 37273b2..b79d93c 100644
--- a/cpp/cmake_modules/BuildUtils.cmake
+++ b/cpp/cmake_modules/BuildUtils.cmake
@@ -298,12 +298,28 @@ endfunction()
 # of 'benchmark'.
 #
 # Arguments after the test name will be passed to set_tests_properties().
+#
+# \arg PREFIX a string to append to the name of the benchmark executable. For
+# example, if you have src/arrow/foo/bar-benchmark.cc, then PREFIX "foo" will
+# create test executable foo-bar-benchmark
 function(ADD_ARROW_BENCHMARK REL_BENCHMARK_NAME)
+  set(options)
+  set(one_value_args)
+  set(multi_value_args EXTRA_LINK_LIBS DEPENDENCIES PREFIX)
+  cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
+  if(ARG_UNPARSED_ARGUMENTS)
+    message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
+  endif()
+
   if(NO_BENCHMARKS)
     return()
   endif()
   get_filename_component(BENCHMARK_NAME ${REL_BENCHMARK_NAME} NAME_WE)
 
+  if(ARG_PREFIX)
+    set(BENCHMARK_NAME "${ARG_PREFIX}-${BENCHMARK_NAME}")
+  endif()
+
   if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${REL_BENCHMARK_NAME}.cc)
     # This benchmark has a corresponding .cc file, set it up as an executable.
     set(BENCHMARK_PATH "${EXECUTABLE_OUTPUT_PATH}/${BENCHMARK_NAME}")
@@ -311,41 +327,25 @@ function(ADD_ARROW_BENCHMARK REL_BENCHMARK_NAME)
     target_link_libraries(${BENCHMARK_NAME} ${ARROW_BENCHMARK_LINK_LIBS})
     add_dependencies(runbenchmark ${BENCHMARK_NAME})
     set(NO_COLOR "--color_print=false")
+
+    if (ARG_EXTRA_LINK_LIBS)
+      target_link_libraries(${BENCHMARK_NAME} ${ARG_EXTRA_LINK_LIBS})
+    endif()
   else()
     # No executable, just invoke the benchmark (probably a script) directly.
     set(BENCHMARK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${REL_BENCHMARK_NAME})
     set(NO_COLOR "")
   endif()
 
+  if (ARG_DEPENDENCIES)
+    add_dependencies(${BENCHMARK_NAME} ${ARG_DEPENDENCIES})
+  endif()
+
   add_test(${BENCHMARK_NAME}
     ${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} benchmark ${BENCHMARK_PATH} ${NO_COLOR})
   set_tests_properties(${BENCHMARK_NAME} PROPERTIES LABELS "benchmark")
-  if(ARGN)
-    set_tests_properties(${BENCHMARK_NAME} PROPERTIES ${ARGN})
-  endif()
-endfunction()
-
-# A wrapper for add_dependencies() that is compatible with NO_BENCHMARKS.
-function(ADD_ARROW_BENCHMARK_DEPENDENCIES REL_BENCHMARK_NAME)
-  if(NO_BENCHMARKS)
-    return()
-  endif()
-  get_filename_component(BENCMARK_NAME ${REL_BENCHMARK_NAME} NAME_WE)
-
-  add_dependencies(${BENCHMARK_NAME} ${ARGN})
 endfunction()
 
-# A wrapper for target_link_libraries() that is compatible with NO_BENCHMARKS.
-function(ARROW_BENCHMARK_LINK_LIBRARIES REL_BENCHMARK_NAME)
-    if(NO_BENCHMARKS)
-    return()
-  endif()
-  get_filename_component(BENCHMARK_NAME ${REL_BENCHMARK_NAME} NAME_WE)
-
-  target_link_libraries(${BENCHMARK_NAME} ${ARGN})
-endfunction()
-
-
 ############################################################
 # Testing
 ############################################################
diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt
index 6070cfb..0381a7b 100644
--- a/cpp/src/parquet/CMakeLists.txt
+++ b/cpp/src/parquet/CMakeLists.txt
@@ -96,6 +96,10 @@ set(PARQUET_STATIC_TEST_LINK_LIBS
   ${ARROW_LIBRARY_TESTING}
   parquet_static)
 
+set(PARQUET_BENCHMARK_LINK_LIBRARIES
+  arrow_benchmark_main
+  parquet_shared)
+
 ############################################################
 # Generated Thrift sources
 
@@ -285,17 +289,9 @@ ADD_PARQUET_TEST(reader-test)
 ADD_PARQUET_TEST(file-deserialize-test USE_STATIC_LINKING)
 ADD_PARQUET_TEST(schema-test USE_STATIC_LINKING)
 
-#############################################################
-# Benchmark linking
-
-set(PARQUET_BENCHMARK_LINK_LIBRARIES
-  arrow_benchmark_main
-  parquet_static)
-
-ADD_ARROW_BENCHMARK(column-io-benchmark)
-ARROW_BENCHMARK_LINK_LIBRARIES(column-io-benchmark
-  ${PARQUET_BENCHMARK_LINK_LIBRARIES})
-
-ADD_ARROW_BENCHMARK(encoding-benchmark)
-ARROW_BENCHMARK_LINK_LIBRARIES(encoding-benchmark
-  ${PARQUET_BENCHMARK_LINK_LIBRARIES})
+ADD_ARROW_BENCHMARK(column-io-benchmark
+  PREFIX "parquet"
+  EXTRA_LINK_LIBS ${PARQUET_BENCHMARK_LINK_LIBRARIES})
+ADD_ARROW_BENCHMARK(encoding-benchmark
+  PREFIX "parquet"
+  EXTRA_LINK_LIBS ${PARQUET_BENCHMARK_LINK_LIBRARIES})
diff --git a/cpp/src/parquet/arrow/CMakeLists.txt b/cpp/src/parquet/arrow/CMakeLists.txt
index aa58a5d..429dadc 100644
--- a/cpp/src/parquet/arrow/CMakeLists.txt
+++ b/cpp/src/parquet/arrow/CMakeLists.txt
@@ -18,11 +18,9 @@
 ADD_PARQUET_TEST(arrow-schema-test)
 ADD_PARQUET_TEST(arrow-reader-writer-test)
 
-if(PARQUET_BUILD_BENCHMARKS)
-  ADD_ARROW_BENCHMARK(arrow-reader-writer-benchmark)
-  ARROW_BENCHMARK_LINK_LIBRARIES(arrow-reader-writer-benchmark
-    ${PARQUET_BENCHMARK_LINK_LIBRARIES})
-endif()
+ADD_ARROW_BENCHMARK(reader-writer-benchmark
+  PREFIX "parquet-arrow"
+  EXTRA_LINK_LIBS ${PARQUET_BENCHMARK_LINK_LIBRARIES})
 
 # Headers: top level
 install(FILES
diff --git a/cpp/src/parquet/arrow/arrow-reader-writer-benchmark.cc b/cpp/src/parquet/arrow/reader-writer-benchmark.cc
similarity index 100%
rename from cpp/src/parquet/arrow/arrow-reader-writer-benchmark.cc
rename to cpp/src/parquet/arrow/reader-writer-benchmark.cc