aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2016-08-28 13:50:09 +0100
committerMarco Poletti <poletti.marco@gmail.com>2016-08-28 13:50:09 +0100
commitd94b25e3508231f59354764e1776ff33fc91c66a (patch)
treeffb70ce0c50826a02b52ff3ff119784d98a433fb /examples
parent1a23d0b7ea137631929c30e77179acd6c540be47 (diff)
downloadgoogle-fruit-d94b25e3508231f59354764e1776ff33fc91c66a.tar.gz
Fix a couple remaining issues with the benchmark code and introduce YAML files to configure the tests to run and the tables to produce with the test results. Also improve code quality of benchmarking code.
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt1
-rw-r--r--examples/compile_time_benchmark/CMakeLists.txt17
-rw-r--r--examples/compile_time_benchmark/module.cpp149
3 files changed, 0 insertions, 167 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 90141a9..3411164 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,5 +1,4 @@
-add_subdirectory(compile_time_benchmark EXCLUDE_FROM_ALL)
add_subdirectory(simple_injection)
add_subdirectory(hello_world)
add_subdirectory(server)
diff --git a/examples/compile_time_benchmark/CMakeLists.txt b/examples/compile_time_benchmark/CMakeLists.txt
deleted file mode 100644
index 2ccc320..0000000
--- a/examples/compile_time_benchmark/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-
-add_custom_target(compile_time_benchmark
- COMMAND echo Release
- COMMAND time ${CMAKE_CXX_COMPILER} -std=c++11 -O2 -W -Wall -Werror -DNDEBUG -ftemplate-depth=1000 -I${CMAKE_CURRENT_SOURCE_DIR}/../../include -I${CMAKE_BINARY_DIR}/include -c ${CMAKE_CURRENT_SOURCE_DIR}/module.cpp -o module.o
- COMMAND echo "Release \"(\"no dep check\")\""
- COMMAND time ${CMAKE_CXX_COMPILER} -std=c++11 -O2 -W -Wall -Werror -DFRUIT_NO_LOOP_CHECK -DNDEBUG -ftemplate-depth=1000 -I${CMAKE_CURRENT_SOURCE_DIR}/../../include -I${CMAKE_BINARY_DIR}/include -c ${CMAKE_CURRENT_SOURCE_DIR}/module.cpp -o module.o
- COMMAND echo "Metaprogramming instantiation stats \"(\"no dep check\")\""
- COMMAND ${CMAKE_CXX_COMPILER} -std=c++11 -O2 -W -Wall -Werror -DFRUIT_TRACE_INSTANTIATIONS -DFRUIT_NO_LOOP_CHECK -DNDEBUG -ftemplate-depth=1000 -I${CMAKE_CURRENT_SOURCE_DIR}/../../include -I${CMAKE_BINARY_DIR}/include -c ${CMAKE_CURRENT_SOURCE_DIR}/module.cpp -o module.o 2>&1 | fgrep "Werror=deprecated-declarations" | sed "'s/.*with MetaFun = //;s/ MetaExprs =.*//;s/.*with MetaExpr =.*/constant/;s/.*static constexpr bool fruit::impl::meta::DoEval<fruit::impl::meta::If.*/If1/;s/.*static constexpr bool fruit::impl::meta::EvalIf.*/If2/'" | sed "'s/fruit::impl::meta:://g'" | sed "'s/::apply<.*>/::apply<...>/'" | sort | uniq -c | sort -n
- #COMMAND echo Debug
- #COMMAND time ${CMAKE_CXX_COMPILER} -std=c++11 -Os -g -W -Wall -Werror -ftemplate-depth=1000 -I${CMAKE_CURRENT_SOURCE_DIR}/../../include -c ${CMAKE_CURRENT_SOURCE_DIR}/module.cpp -o module.o
- #COMMAND echo "Debug \"(\"no dep check\")\""
- #COMMAND time ${CMAKE_CXX_COMPILER} -std=c++11 -Os -g -W -Wall -Werror -DFRUIT_NO_LOOP_CHECK -ftemplate-depth=1000 -I${CMAKE_CURRENT_SOURCE_DIR}/../../include -c ${CMAKE_CURRENT_SOURCE_DIR}/module.cpp -o module.o
- )
-
-# This is just to help IDEs (e.g. CLion) figure out how module.cpp is supposed to be built.
-add_executable(compile_time_benchmark_executable EXCLUDE_FROM_ALL module.cpp)
-target_link_libraries(compile_time_benchmark_executable fruit)
diff --git a/examples/compile_time_benchmark/module.cpp b/examples/compile_time_benchmark/module.cpp
deleted file mode 100644
index eb2b734..0000000
--- a/examples/compile_time_benchmark/module.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2014 Google Inc. All rights reserved.
- *
- * Licensed 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 <fruit/fruit.h>
-
-#if MULTIPLIER == 1
-#define REPEAT(X) REPEAT_1(X, _)
-
-#elif MULTIPLIER == 2
-#define REPEAT(X) REPEAT_2(X, _)
-
-#elif MULTIPLIER == 4
-#define REPEAT(X) REPEAT_4(X, _)
-
-#elif MULTIPLIER == 8
-#define REPEAT(X) REPEAT_8(X, _)
-
-#elif MULTIPLIER == 16
-#define REPEAT(X) REPEAT_16(X, _)
-
-#elif MULTIPLIER == 32
-#define REPEAT(X) REPEAT_32(X, _)
-
-#elif MULTIPLIER == 64
-#define REPEAT(X) REPEAT_64(X, _)
-
-#elif MULTIPLIER == 128
-#define REPEAT(X) REPEAT_128(X, _)
-
-#elif MULTIPLIER == 256
-#define REPEAT(X) REPEAT_256(X, _)
-
-#elif MULTIPLIER == 512
-#define REPEAT(X) REPEAT_512(X, _)
-
-#elif MULTIPLIER == 1024
-#define REPEAT(X) REPEAT_1024(X, _)
-
-#else
-#error Multiplier not supported.
-#endif
-
-#define PLACEHOLDER
-
-#define EVAL0(...) __VA_ARGS__
-#define EVAL1(...) EVAL0(EVAL0(EVAL0(EVAL0(__VA_ARGS__))))
-#define EVAL2(...) EVAL1(EVAL1(EVAL1(EVAL1(__VA_ARGS__))))
-#define EVAL(...) EVAL2(EVAL2(EVAL2(EVAL2(__VA_ARGS__))))
-
-#define META_REPEAT_2(R, X, I) \
-R PLACEHOLDER(X, I##0) \
-R PLACEHOLDER(X, I##1)
-
-#define REPEAT_1(X, I) \
-X(I)
-
-#define REPEAT_2(X, I) \
-META_REPEAT_2(REPEAT_1, X, I)
-
-#define REPEAT_4(X, I) \
-META_REPEAT_2(REPEAT_2, X, I)
-
-#define REPEAT_8(X, I) \
-META_REPEAT_2(REPEAT_4, X, I)
-
-#define REPEAT_16(X, I) \
-META_REPEAT_2(REPEAT_8, X, I)
-
-#define REPEAT_32(X, I) \
-META_REPEAT_2(REPEAT_16, X, I)
-
-#define REPEAT_64(X, I) \
-META_REPEAT_2(REPEAT_32, X, I)
-
-#define REPEAT_128(X, I) \
-META_REPEAT_2(REPEAT_64, X, I)
-
-#define REPEAT_256(X, I) \
-META_REPEAT_2(REPEAT_128, X, I)
-
-#define REPEAT_512(X, I) \
-META_REPEAT_2(REPEAT_256, X, I)
-
-#define REPEAT_1024(X, I) \
-META_REPEAT_2(REPEAT_512, X, I)
-
-using namespace fruit;
-
-#define DEFINITIONS(N) \
-struct A##N { \
- INJECT(A##N()) = default; \
-}; \
- \
-struct B##N { \
-}; \
- \
-struct C##N { \
-}; \
- \
-struct I##N { \
- virtual void f() = 0; \
-}; \
- \
-struct X##N : public I##N { \
- INJECT(X##N(A##N, B##N*, const C##N&)) {}; \
- \
- virtual void f(); \
-}; \
- \
-struct Y##N { \
-}; \
- \
-struct Z##N { \
-}; \
- \
-Component<Required<Y##N>, Z##N> getZ##N##Component(); \
-
-#define REQUIREMENTS(N) \
-C##N,
-
-#define PARAMETERS(N) \
-B##N& b##N,
-
-#define BINDINGS(N) \
- .bind<I##N, X##N>() \
- .bindInstance(b##N) \
- .install(getZ##N##Component()) \
- .registerProvider([](){return Y##N();})
-
-EVAL(REPEAT(DEFINITIONS))
-
-Component<Required<EVAL(REPEAT(REQUIREMENTS)) int>> getComponent(EVAL(REPEAT(PARAMETERS)) int) {
- return createComponent()
- EVAL(REPEAT(BINDINGS))
- ;
-}