forked from BoostGSoC19/Real
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memory fixes, and large refactor. Replaces many raw ptrs with shared_…
…ptr. Uses std::variant.
- Loading branch information
1 parent
527f196
commit 8d8b26d
Showing
38 changed files
with
1,907 additions
and
1,962 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ ignore: | |
- "doc/**" | ||
- "external/**" | ||
- "test/**" | ||
"bench/**" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ CMakeFiles/ | |
CMakeScripts/ | ||
CTestTestfile.cmake | ||
cmake_install.cmake | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Suppressing benchmark's tests" FORCE) | ||
|
||
add_subdirectory(benchmark) | ||
include_directories(benchmark/include | ||
include) | ||
|
||
set(bench_list | ||
addition_bench.cpp | ||
# remember to add src's here | ||
set(benchSrcs | ||
operation_tree_bench.cpp | ||
main_bench.cpp | ||
) | ||
|
||
add_executable(main_bench ${bench_list}) | ||
|
||
|
||
target_link_libraries(main_bench | ||
benchmark | ||
Boost.Real | ||
${CMAKE_THREAD_LIBS_INIT} | ||
# to run a subset of benchmarks, use: | ||
# ./main_bench --benchmark_filter=<regex> | ||
add_executable(main_bench ${benchSrcs}) | ||
target_include_directories(main_bench | ||
PRIVATE ./include | ||
) | ||
target_link_libraries(main_bench | ||
PUBLIC Boost.Real | ||
PUBLIC benchmark | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <iostream> | ||
|
||
|
||
class NullBuffer : public std::streambuf | ||
{ | ||
public: | ||
int overflow(int c) { return c; } | ||
}; | ||
|
||
class NullStream: public std::ostream | ||
{ | ||
public: | ||
NullStream() : std::ostream(&sb) {} | ||
|
||
private: | ||
NullBuffer sb; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
#ifndef BOOST_REAL_BENCH_HELPERS_HPP | ||
#define BOOST_REAL_BENCH_HELPERS_HPP | ||
|
||
|
||
#include <benchmark/benchmark.h> | ||
#include <real/real.hpp> | ||
|
||
unsigned int boost::real::real::maximum_precision = 10; | ||
unsigned int boost::real::real_algorithm::maximum_precision = 10; | ||
|
||
#endif //BOOST_REAL_BENCH_HELPERS_HPP | ||
BENCHMARK_MAIN(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <benchmark/benchmark.h> | ||
#include <real/real.hpp> | ||
#include <benchmark_helpers.hpp> | ||
|
||
/** @file benchmark the operation trees, | ||
* with different kinds of leaves, and/or a large number of nodes. | ||
*/ | ||
|
||
// constants used in the benchmarks | ||
const int MIN_TREE_SIZE = 8; | ||
const int MAX_TREE_SIZE = 16; | ||
|
||
// used to force evaluation, without console output | ||
NullStream null_stream; | ||
|
||
// trees between MIN_TREE_SIZE and MAX_TREE_SIZE of single operations | ||
static void BM_RealAdditionTree(benchmark::State& state) { | ||
boost::real::real a ("1.2"); | ||
boost::real::real c ("0"); | ||
|
||
for (auto i : state) | ||
for (int i = 0; i < state.range(0); i++) | ||
c += a; | ||
null_stream << c << '\n'; | ||
} | ||
BENCHMARK(BM_RealAdditionTree)->Range(MIN_TREE_SIZE,MAX_TREE_SIZE)->Unit(benchmark::kMillisecond); | ||
|
||
static void BM_RealSubtractionTree(benchmark::State& state) { | ||
boost::real::real a ("1"); | ||
boost::real::real c ("9999"); | ||
|
||
for (auto i : state) | ||
{ | ||
for (int i = 0; i < state.range(0); i++) | ||
c -= a; | ||
null_stream << c << '\n'; | ||
} | ||
} | ||
BENCHMARK(BM_RealSubtractionTree)->Range(MIN_TREE_SIZE,MAX_TREE_SIZE)->Unit(benchmark::kMillisecond); | ||
|
||
static void BM_RealMultiplicationTree(benchmark::State& state) { | ||
boost::real::real a ("1"); | ||
boost::real::real c ("9"); | ||
|
||
for (auto i : state) | ||
{ | ||
for (int i = 0; i < state.range(0); i++) | ||
c *= a; | ||
null_stream << c << '\n'; | ||
} | ||
} | ||
BENCHMARK(BM_RealMultiplicationTree)->Range(MIN_TREE_SIZE,MAX_TREE_SIZE)->Unit(benchmark::kMillisecond); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.