From 904d05f55b28f3d4ecc3702eae521ff8bda77533 Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Mon, 13 Aug 2018 01:44:58 +0200 Subject: [PATCH] fix of speed_cpp and ignore some warnings in release mode --- include/boost/histogram/detail/axes.hpp | 4 + test/speed_cpp.cpp | 102 +++++++----------------- 2 files changed, 35 insertions(+), 71 deletions(-) diff --git a/include/boost/histogram/detail/axes.hpp b/include/boost/histogram/detail/axes.hpp index f0da6834..1dfb095d 100644 --- a/include/boost/histogram/detail/axes.hpp +++ b/include/boost/histogram/detail/axes.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -244,11 +245,14 @@ void dimension_check(const static_axes&, std::size_t n) { template void dimension_check(const dynamic_axes& axes, mp11::mp_size_t) { BOOST_ASSERT_MSG(axes.size() == N, "number of arguments does not match"); + boost::ignore_unused(axes); } template void dimension_check(const dynamic_axes& axes, std::size_t n) { BOOST_ASSERT_MSG(axes.size() == n, "number of arguments does not match"); + boost::ignore_unused(axes); + boost::ignore_unused(n); } struct shape_collector { diff --git a/test/speed_cpp.cpp b/test/speed_cpp.cpp index 3dd1cc7d..798a8e2a 100644 --- a/test/speed_cpp.cpp +++ b/test/speed_cpp.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "utility.hpp" using namespace boost::histogram; using boost::mp11::mp_list; @@ -48,13 +49,13 @@ double baseline(unsigned n) { return best; } -template +template double compare_1d(unsigned n, int distrib) { auto r = random_array(n, distrib); auto best = std::numeric_limits::max(); for (unsigned k = 0; k < 20; ++k) { - auto h = Histogram(axis::regular<>(100, 0, 1)); + auto h = make_s(Tag(), Storage(), axis::regular<>(100, 0, 1)); auto t = clock(); for (unsigned i = 0; i < n; ++i) h(r[i]); t = clock() - t; @@ -64,14 +65,14 @@ double compare_1d(unsigned n, int distrib) { return best; } -template +template double compare_2d(unsigned n, int distrib) { auto r = random_array(n, distrib); auto best = std::numeric_limits::max(); for (unsigned k = 0; k < 20; ++k) { auto h = - Histogram(axis::regular<>(100, 0, 1), axis::regular<>(100, 0, 1)); + make_s(Tag(), Storage(), axis::regular<>(100, 0, 1), axis::regular<>(100, 0, 1)); auto t = clock(); for (unsigned i = 0; i < n / 2; ++i) h(r[2 * i], r[2 * i + 1]); t = clock() - t; @@ -81,17 +82,16 @@ double compare_2d(unsigned n, int distrib) { return best; } -template +template double compare_3d(unsigned n, int distrib) { auto r = random_array(n, distrib); auto best = std::numeric_limits::max(); for (unsigned k = 0; k < 20; ++k) { - auto h = Histogram(axis::regular<>(100, 0, 1), axis::regular<>(100, 0, 1), - axis::regular<>(100, 0, 1)); + auto h = make_s(Tag(), Storage(), axis::regular<>(100, 0, 1), + axis::regular<>(100, 0, 1), axis::regular<>(100, 0, 1)); auto t = clock(); - for (unsigned i = 0; i < n / 3; ++i) - h(r[3 * i], r[3 * i + 1], r[3 * i + 2]); + for (unsigned i = 0; i < n / 3; ++i) h(r[3 * i], r[3 * i + 1], r[3 * i + 2]); t = clock() - t; best = std::min(best, double(t) / CLOCKS_PER_SEC); } @@ -99,20 +99,20 @@ double compare_3d(unsigned n, int distrib) { return best; } -template +template double compare_6d(unsigned n, int distrib) { auto r = random_array(n, distrib); auto best = std::numeric_limits::max(); for (unsigned k = 0; k < 20; ++k) { - auto h = Histogram(axis::regular<>(10, 0, 1), axis::regular<>(10, 0, 1), - axis::regular<>(10, 0, 1), axis::regular<>(10, 0, 1), - axis::regular<>(10, 0, 1), axis::regular<>(10, 0, 1)); + auto h = + make_s(Tag(), Storage(), axis::regular<>(10, 0, 1), axis::regular<>(10, 0, 1), + axis::regular<>(10, 0, 1), axis::regular<>(10, 0, 1), + axis::regular<>(10, 0, 1), axis::regular<>(10, 0, 1)); auto t = clock(); for (unsigned i = 0; i < n / 6; ++i) { - h(r[6 * i], r[6 * i + 1], r[6 * i + 2], r[6 * i + 3], r[6 * i + 4], - r[6 * i + 5]); + h(r[6 * i], r[6 * i + 1], r[6 * i + 2], r[6 * i + 3], r[6 * i + 4], r[6 * i + 5]); } t = clock() - t; best = std::min(best, double(t) / CLOCKS_PER_SEC); @@ -132,18 +132,10 @@ int main() { printf("uniform distribution\n"); else printf("normal distribution\n"); - printf("hs_ss %.3f\n", - compare_1d>, - array_storage>>(nfill, itype)); - printf("hs_sd %.3f\n", - compare_1d>, - adaptive_storage<>>>(nfill, itype)); - printf("hd_ss %.3f\n", - compare_1d>>( - nfill, itype)); - printf("hd_sd %.3f\n", - compare_1d>>( - nfill, itype)); + printf("hs_ss %.3f\n", compare_1d>(nfill, itype)); + printf("hs_sd %.3f\n", compare_1d>(nfill, itype)); + printf("hd_ss %.3f\n", compare_1d>(nfill, itype)); + printf("hd_sd %.3f\n", compare_1d>(nfill, itype)); } printf("2D\n"); @@ -152,20 +144,10 @@ int main() { printf("uniform distribution\n"); else printf("normal distribution\n"); - printf( - "hs_ss %.3f\n", - compare_2d, axis::regular<>>, - array_storage>>(nfill, itype)); - printf( - "hs_sd %.3f\n", - compare_2d, axis::regular<>>, - adaptive_storage<>>>(nfill, itype)); - printf("hd_ss %.3f\n", - compare_2d>>( - nfill, itype)); - printf("hd_sd %.3f\n", - compare_2d>>( - nfill, itype)); + printf("hs_ss %.3f\n", compare_2d>(nfill, itype)); + printf("hs_sd %.3f\n", compare_2d>(nfill, itype)); + printf("hd_ss %.3f\n", compare_2d>(nfill, itype)); + printf("hd_sd %.3f\n", compare_2d>(nfill, itype)); } printf("3D\n"); @@ -174,20 +156,10 @@ int main() { printf("uniform distribution\n"); else printf("normal distribution\n"); - printf("hs_ss %.3f\n", - compare_3d, axis::regular<>, axis::regular<>>, - array_storage>>(nfill, itype)); - printf("hs_sd %.3f\n", - compare_3d, axis::regular<>, axis::regular<>>, - adaptive_storage<>>>(nfill, itype)); - printf("hd_ss %.3f\n", - compare_3d>>( - nfill, itype)); - printf("hd_sd %.3f\n", - compare_3d>>( - nfill, itype)); + printf("hs_ss %.3f\n", compare_3d>(nfill, itype)); + printf("hs_sd %.3f\n", compare_3d>(nfill, itype)); + printf("hd_ss %.3f\n", compare_3d>(nfill, itype)); + printf("hd_sd %.3f\n", compare_3d>(nfill, itype)); } printf("6D\n"); @@ -196,21 +168,9 @@ int main() { printf("uniform distribution\n"); else printf("normal distribution\n"); - printf("hs_ss %.3f\n", - compare_6d, axis::regular<>, axis::regular<>, - axis::regular<>, axis::regular<>, axis::regular<>>, - array_storage>>(nfill, itype)); - printf("hs_sd %.3f\n", - compare_6d, axis::regular<>, axis::regular<>, - axis::regular<>, axis::regular<>, axis::regular<>>, - adaptive_storage<>>>(nfill, itype)); - printf("hd_ss %.3f\n", - compare_6d>>( - nfill, itype)); - printf("hd_sd %.3f\n", - compare_6d>>( - nfill, itype)); + printf("hs_ss %.3f\n", compare_6d>(nfill, itype)); + printf("hs_sd %.3f\n", compare_6d>(nfill, itype)); + printf("hd_ss %.3f\n", compare_6d>(nfill, itype)); + printf("hd_sd %.3f\n", compare_6d>(nfill, itype)); } }