diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 4b2624f1..283658c9 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -77,28 +77,7 @@ endif() # checks if(BUILD_CHECKS) - add_executable(speed_cpp_hs_ss - ../test/speed_cpp.cpp) - target_link_libraries(speed_cpp_hs_ss ${LIBRARIES}) - target_compile_definitions(speed_cpp_hs_ss PUBLIC HISTOGRAM_TYPE=1) - - add_executable(speed_cpp_hs_sd - ../test/speed_cpp.cpp) - target_link_libraries(speed_cpp_hs_sd ${LIBRARIES}) - target_compile_definitions(speed_cpp_hs_sd PUBLIC HISTOGRAM_TYPE=2) - - add_executable(speed_cpp_hd_ss - ../test/speed_cpp.cpp) - target_link_libraries(speed_cpp_hd_ss ${LIBRARIES}) - target_compile_definitions(speed_cpp_hd_ss PUBLIC HISTOGRAM_TYPE=3) - - add_executable(speed_cpp_hd_sd - ../test/speed_cpp.cpp) - target_link_libraries(speed_cpp_hd_sd ${LIBRARIES}) - target_compile_definitions(speed_cpp_hd_sd PUBLIC HISTOGRAM_TYPE=4) - - add_executable(axis_size - ../test/axis_size.cpp) + add_executable(speed_cpp ../test/speed_cpp.cpp) endif() # tests diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index c63d30be..ef795750 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -23,6 +23,13 @@ doxygen autodoc USE_MATHJAX=YES ; +exe speed + : ../test/speed_cpp.cpp + : release + 256 + "-std=c++11" + ; + boostbook standalone : histogram.qbk diff --git a/test/speed_cpp.cpp b/test/speed_cpp.cpp index 70b39048..ec332e32 100644 --- a/test/speed_cpp.cpp +++ b/test/speed_cpp.cpp @@ -4,12 +4,7 @@ // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) -#include -#include -#include -#include -#include - +#include #include #include #include @@ -18,7 +13,7 @@ #include using namespace boost::histogram; -namespace mpl = boost::mpl; +namespace mpl = boost::mpl; std::vector random_array(unsigned n, int type) { std::vector result(n); @@ -42,7 +37,7 @@ double compare_1d(unsigned n, int distrib) auto r = random_array(n, distrib); auto best = std::numeric_limits::max(); - for (unsigned k = 0; k < 10; ++k) { + for (unsigned k = 0; k < 50; ++k) { auto h = Histogram(regular_axis(100, 0, 1)); auto t = clock(); for (unsigned i = 0; i < n; ++i) @@ -60,7 +55,7 @@ double compare_3d(unsigned n, int distrib) auto r = random_array(3 * n, distrib); auto best = std::numeric_limits::max(); - for (unsigned k = 0; k < 10; ++k) { + for (unsigned k = 0; k < 50; ++k) { auto h = Histogram(regular_axis(100, 0, 1), regular_axis(100, 0, 1), regular_axis(100, 0, 1)); @@ -69,7 +64,7 @@ double compare_3d(unsigned n, int distrib) h.fill(r[3 * i], r[3 * i + 1], r[3 * i + 2]); t = clock() - t; best = std::min(best, double(t) / CLOCKS_PER_SEC); - } + } return best; } @@ -80,7 +75,7 @@ double compare_6d(unsigned n, int distrib) auto r = random_array(6 * n, distrib); auto best = std::numeric_limits::max(); - for (unsigned k = 0; k < 10; ++k) { + for (unsigned k = 0; k < 50; ++k) { double x[6]; auto h = Histogram(regular_axis(10, 0, 1), @@ -93,92 +88,104 @@ double compare_6d(unsigned n, int distrib) auto t = clock(); for (unsigned i = 0; i < n; ++i) { for (unsigned k = 0; k < 6; ++k) - x[k] = r[6 * i + k]; + x[k] = r[6 * i + k]; h.fill(x[0], x[1], x[2], x[3], x[4], x[5]); } t = clock() - t; best = std::min(best, double(t) / CLOCKS_PER_SEC); - } + } return best; } int main() { + printf("1D\n"); for (int itype = 0; itype < 2; ++itype) { if (itype == 0) printf("uniform distribution\n"); else printf("normal distribution\n"); - - printf("1D\n"); - printf("t[boost] = %.3f\n", -#if HISTOGRAM_TYPE == 1 + printf("t[hs_ss] %.3f\n", compare_1d< static_histogram< mpl::vector, container_storage> > >(12000000, itype) -#elif HISTOGRAM_TYPE == 2 + ); + printf("t[hs_sd] %.3f\n", compare_1d< static_histogram< mpl::vector, adaptive_storage<> > >(12000000, itype) -#elif HISTOGRAM_TYPE == 3 + ); + printf("t[hd_ss] %.3f\n", compare_1d< dynamic_histogram< default_axes, container_storage> > >(12000000, itype) -#elif HISTOGRAM_TYPE == 4 + ); + printf("t[hd_sd] %.3f\n", compare_1d< dynamic_histogram< default_axes, adaptive_storage<> > >(12000000, itype) -#endif ); + } - printf("3D\n"); - printf("t[boost] = %.3f\n", -#if HISTOGRAM_TYPE == 1 + printf("3D\n"); + for (int itype = 0; itype < 2; ++itype) { + if (itype == 0) + printf("uniform distribution\n"); + else + printf("normal distribution\n"); + printf("t[hs_ss] %.3f\n", compare_3d< static_histogram< mpl::vector, container_storage> > >(4000000, itype) -#elif HISTOGRAM_TYPE == 2 + ); + printf("t[hs_sd] %.3f\n", compare_3d< static_histogram< mpl::vector, adaptive_storage<> > >(4000000, itype) -#elif HISTOGRAM_TYPE == 3 + ); + printf("t[hd_ss] %.3f\n", compare_3d< dynamic_histogram< default_axes, container_storage> > >(4000000, itype) -#elif HISTOGRAM_TYPE == 4 + ); + printf("t[hd_sd] %.3f\n", compare_3d< dynamic_histogram< default_axes, adaptive_storage<> > >(4000000, itype) -#endif ); + } - printf("6D\n"); - printf("t[boost] = %.3f\n", -#if HISTOGRAM_TYPE == 1 + printf("6D\n"); + for (int itype = 0; itype < 2; ++itype) { + if (itype == 0) + printf("uniform distribution\n"); + else + printf("normal distribution\n"); + printf("t[hs_ss] %.3f\n", compare_6d< static_histogram< mpl::vector> > >(2000000, itype) -#elif HISTOGRAM_TYPE == 2 + ); + printf("t[hs_sd] %.3f\n", compare_6d< static_histogram< mpl::vector > >(2000000, itype) -#elif HISTOGRAM_TYPE == 3 + ); + printf("t[hd_ss] %.3f\n", compare_6d< dynamic_histogram< default_axes, container_storage> > >(2000000, itype) -#elif HISTOGRAM_TYPE == 4 + ); + printf("t[hd_sd] %.3f\n", compare_6d< dynamic_histogram< default_axes, adaptive_storage<> > >(2000000, itype) -#endif ); } }