Skip to content
Permalink
Browse files
GEODE-5188 - Adds benchmarking framework. (#293)
* Prevent optimization of bench.
* Adds benchmark framework.
* Refactor for shared integration framework.
* Adds some get benchmarks.
* Fixes Rat checking
  • Loading branch information
pivotal-jbarrett committed Dec 18, 2018
1 parent 3882b00 commit e4b2577305e015f38249db70c23b49b2a0523df6
Show file tree
Hide file tree
Showing 52 changed files with 894 additions and 123 deletions.

This file was deleted.

@@ -1,40 +1,39 @@
# text files
.*\.clang-format$
.*\.clang-tidy$
.*\.cpackignore$
.*\.gitignore$
.*\.lcovrc$
.*\.ratignore$
.*\.lgtm.yml$
.*\.ratCheck.sh$
# rat -E only matches filename components
# All matches are anchored automatically to who string

.*md$
.*json$
.*deprecated_xml_instructions.txt$
# /
\.clang-format
\.clang-tidy
\.gitignore
\.ratignore
\.lgtm.yml
\.lcovrc
\.cpackignore

# generated files
.*Resources.Designer.cs$
.*Settings.Designer.cs$
# dependencies/*/
patches

# public domain
.*CPPDictionary.hpp$
.*CPPSymbol.hpp$
.*CPP_parser.g$
.*DictEntry.hpp$
.*Dictionary.cpp$
.*Dictionary.hpp$
.*STDCTokenTypes.txt$
.*Support.cpp$
# packer/*/
.*\.cloud-init
.*\.json

# expect script
.*changepasswd$
.*winrm.cloud-init$
# docs/
Gemfile.lock
package-list
.*\.md
.*\.md.erb

# doxygen
.*package-list$
.*testframeworkdox.txt$
docs
# contrib/pdxautoserializer
# public domain sources
CPPDictionary.hpp
CPPSymbol.hpp
CPP_parser.g
DictEntry.hpp
Dictionary.cpp
Dictionary.hpp
STDCTokenTypes.txt
Support.cpp

# patches
.*patches$
.*ACE.config.h.in$
# well known build directories
build
cmake-build-.*
@@ -29,8 +29,8 @@ env:
- SOURCE_DIR="/geode-native"

matrix:
- DOCKER_COMMAND="cd ${SOURCE_DIR} && ./.ratCheck.sh"
- DOCKER_COMMAND="mkdir build && cd build && cmake ${SOURCE_DIR} -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_CXX_CLANG_TIDY=clang-tidy && cmake --build . -- -j2 && ./cppcache/test/apache-geode_unittests && git -C ${SOURCE_DIR} diff --exit-code"
- DOCKER_COMMAND="echo rat && mkdir build && cd build && cmake ${SOURCE_DIR} -DUSE_RAT=ON && cmake --build . --target rat-check"
- DOCKER_COMMAND="echo test && mkdir build && cd build && cmake ${SOURCE_DIR} -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_CXX_CLANG_TIDY=clang-tidy && cmake --build . -- -j2 && ./cppcache/test/apache-geode_unittests && git -C ${SOURCE_DIR} diff --exit-code"

install:
- docker pull "${DOCKER_IMAGE}"
@@ -17,7 +17,8 @@ cmake_minimum_required(VERSION 3.12)
project(nativeclient LANGUAGES C CXX)

option(USE_PCH "Use precompiled headers (PCH)." OFF)
option(USE_CPP_COVERAGE "Enable profiling and coverage report analysis for apache-geode cpp library" OFF)
option(USE_CPP_COVERAGE "Enable profiling and coverage report analysis for apache-geode cpp library." OFF)
option(USE_RAT "Enable Apache Rat checking." OFF)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

@@ -40,6 +41,7 @@ endif()
set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "4.5.2")
set(DOTNET_TARGET_FRAMEWORK_VERSION "4.5.2")
set(BUILD_BITS 64 CACHE STRING "Build for 64 (Geode default) or 32 bit.")
option(BUILD_BENCHMARKS "Build benchmarks" ON)

set(PRODUCT_VENDOR "Apache" CACHE STRING "Product vendor")
set(PRODUCT_VENDOR_NAME "The Apache Software Foundation" CACHE STRING "Product vendor full legal name")
@@ -363,3 +365,14 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/templates/ DESTINATION templates
PATTERN "templates/security/CMakeLists.txt" EXCLUDE
PATTERN "templates/security/CMakeLists.txt.forInstall" EXCLUDE)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/templates/security/CMakeLists.txt.forInstall RENAME CMakeLists.txt DESTINATION templates/security)

if (USE_RAT)
add_custom_target( rat-check
COMMAND ${CMAKE_COMMAND}
-DJava_JAVA_EXECUTABLE=${Java_JAVA_EXECUTABLE}
-DRat_JAR=${Rat_JAR}
-P cmake/RatCheck.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Checking source with Apache Rat."
)
endif()
@@ -0,0 +1,32 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

execute_process(
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${Rat_JAR} -d . -E .ratignore >
OUTPUT_VARIABLE ratOutput
)

set(pass FALSE)
if (ratOutput MATCHES "([0-9]+) Unknown Licenses")
set(unknownLicenses ${CMAKE_MATCH_1})
if (unknownLicenses GREATER 0)
message(SEND_ERROR "${ratOutput}")
message(FATAL_ERROR "${unknownLicenses} Unknown licenses detected.")
endif()
else()
message(SEND_ERROR "${ratOutput}")
message(FATAL_ERROR "Unknown failure")
endif()
@@ -129,5 +129,9 @@ add_subdirectory(shared)
add_subdirectory(static)
add_subdirectory(test)
add_subdirectory(internal)
add_subdirectory(integration)
add_subdirectory(integration-test)
add_subdirectory(integration-test-2)

if (BUILD_BENCHMARKS)
add_subdirectory(benchmark)
endif()
@@ -0,0 +1,37 @@
Contents
========


## Main sources

# include/
Public include header files for C++ library.

# src/
Sources for both static and shared C++ library.

# shared/
Shared library definition only. Should not contain any sources.

# static/
Static library definition only. Should not contain any sources.


## Test and Benchmark sources

# integration/
Integration syle tests, benchmarks, and common sources. These are all "modern"
single process style and shoult not use any of the "legacy" multiple process
framework.

## integrtion-test/
Legacy integration tests written in the multiple process framework. No new tests
should be added to this collections. Fixes and rewrites should be migrated to
the new framework in the _integration/test_ directory metioned above.

## test/
Unit style tests.

## benchmark/
Unit style or micro benchmark tests.

@@ -0,0 +1,34 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_executable(cpp-benchmark
main.cpp
GeodeHashBM.cpp
)

target_link_libraries(cpp-benchmark
PUBLIC
apache-geode-static
benchmark::benchmark
PRIVATE
_WarningsAsError
)

target_include_directories(cpp-benchmark
PRIVATE
$<TARGET_PROPERTY:apache-geode-static,SOURCE_DIR>/../src
)

add_clangformat(cpp-benchmark)
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <benchmark/benchmark.h>

#include <geode/CacheableString.hpp>

#include "util/string.hpp"

using apache::geode::client::to_utf16;
using apache::geode::client::internal::geode_hash;

class GeodeHashBM : public benchmark::Fixture {};

BENCHMARK_DEFINE_F(GeodeHashBM, std_string)(benchmark::State& state) {
std::string x(state.range(0), 'x');
for (auto _ : state) {
int hashcode;
benchmark::DoNotOptimize(hashcode = geode_hash<std::string>{}(x));
}
}
BENCHMARK_REGISTER_F(GeodeHashBM, std_string)->Range(8, 8 << 10);

BENCHMARK_DEFINE_F(GeodeHashBM, std_u16string)(benchmark::State& state) {
std::u16string x(state.range(0), u'x');
for (auto _ : state) {
int hashcode;
benchmark::DoNotOptimize(hashcode = geode_hash<std::u16string>{}(x));
}
}
BENCHMARK_REGISTER_F(GeodeHashBM, std_u16string)->Range(8, 8 << 10);
@@ -0,0 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <benchmark/benchmark.h>

BENCHMARK_MAIN();
@@ -0,0 +1,21 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_subdirectory(framework)
add_subdirectory(test)

if (BUILD_BENCHMARKS)
add_subdirectory(benchmark)
endif()
@@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_executable(cpp-integration-benchmark
main.cpp
RegionBM.cpp
)

target_link_libraries(cpp-integration-benchmark
PUBLIC
apache-geode
benchmark::benchmark
integration-framework
PRIVATE
_WarningsAsError
)

add_clangformat(cpp-integration-benchmark)

0 comments on commit e4b2577

Please sign in to comment.