mirror of
https://github.com/boostorg/histogram.git
synced 2026-01-29 07:32:23 +00:00
unified both histogram classes
This commit is contained in:
@@ -47,6 +47,22 @@ template <typename Histogram> double compare_1d(unsigned n, int distrib) {
|
||||
return best;
|
||||
}
|
||||
|
||||
template <typename Histogram> double compare_2d(unsigned n, int distrib) {
|
||||
auto r = random_array(2 * n, distrib);
|
||||
|
||||
auto best = std::numeric_limits<double>::max();
|
||||
for (unsigned k = 0; k < 50; ++k) {
|
||||
auto h = Histogram(regular_axis<>(100, 0, 1), regular_axis<>(100, 0, 1));
|
||||
auto t = clock();
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
h.fill(r[2 * i], r[2 * i + 1]);
|
||||
t = clock() - t;
|
||||
best = std::min(best, double(t) / CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
template <typename Histogram> double compare_3d(unsigned n, int distrib) {
|
||||
auto r = random_array(3 * n, distrib);
|
||||
|
||||
@@ -96,21 +112,44 @@ int main() {
|
||||
else
|
||||
printf("normal distribution\n");
|
||||
printf("hs_ss %.3f\n",
|
||||
compare_1d<static_histogram<mpl::vector<regular_axis<>>,
|
||||
compare_1d<histogram<false,mpl::vector<regular_axis<>>,
|
||||
container_storage<std::vector<int>>>>(
|
||||
12000000, itype));
|
||||
printf("hs_sd %.3f\n",
|
||||
compare_1d<static_histogram<mpl::vector<regular_axis<>>,
|
||||
compare_1d<histogram<false,mpl::vector<regular_axis<>>,
|
||||
adaptive_storage<>>>(12000000, itype));
|
||||
printf("hd_ss %.3f\n",
|
||||
compare_1d<dynamic_histogram<default_axes,
|
||||
compare_1d<histogram<true, default_axes,
|
||||
container_storage<std::vector<int>>>>(
|
||||
12000000, itype));
|
||||
printf("hd_sd %.3f\n",
|
||||
compare_1d<dynamic_histogram<default_axes, adaptive_storage<>>>(
|
||||
compare_1d<histogram<true, default_axes, adaptive_storage<>>>(
|
||||
12000000, itype));
|
||||
}
|
||||
|
||||
printf("2D\n");
|
||||
for (int itype = 0; itype < 2; ++itype) {
|
||||
if (itype == 0)
|
||||
printf("uniform distribution\n");
|
||||
else
|
||||
printf("normal distribution\n");
|
||||
printf("hs_ss %.3f\n",
|
||||
compare_2d<histogram<false,
|
||||
mpl::vector<regular_axis<>, regular_axis<>>,
|
||||
container_storage<std::vector<int>>>>(6000000, itype));
|
||||
printf("hs_sd %.3f\n",
|
||||
compare_2d<histogram<false,
|
||||
mpl::vector<regular_axis<>, regular_axis<>>,
|
||||
adaptive_storage<>>>(6000000, itype));
|
||||
printf("hd_ss %.3f\n",
|
||||
compare_2d<histogram<true, default_axes,
|
||||
container_storage<std::vector<int>>>>(
|
||||
6000000, itype));
|
||||
printf("hd_sd %.3f\n",
|
||||
compare_2d<histogram<true, default_axes, adaptive_storage<>>>(
|
||||
6000000, itype));
|
||||
}
|
||||
|
||||
printf("3D\n");
|
||||
for (int itype = 0; itype < 2; ++itype) {
|
||||
if (itype == 0)
|
||||
@@ -118,19 +157,19 @@ int main() {
|
||||
else
|
||||
printf("normal distribution\n");
|
||||
printf("hs_ss %.3f\n",
|
||||
compare_3d<static_histogram<
|
||||
compare_3d<histogram<false,
|
||||
mpl::vector<regular_axis<>, regular_axis<>, regular_axis<>>,
|
||||
container_storage<std::vector<int>>>>(4000000, itype));
|
||||
printf("hs_sd %.3f\n",
|
||||
compare_3d<static_histogram<
|
||||
compare_3d<histogram<false,
|
||||
mpl::vector<regular_axis<>, regular_axis<>, regular_axis<>>,
|
||||
adaptive_storage<>>>(4000000, itype));
|
||||
printf("hd_ss %.3f\n",
|
||||
compare_3d<dynamic_histogram<default_axes,
|
||||
compare_3d<histogram<true, default_axes,
|
||||
container_storage<std::vector<int>>>>(
|
||||
4000000, itype));
|
||||
printf("hd_sd %.3f\n",
|
||||
compare_3d<dynamic_histogram<default_axes, adaptive_storage<>>>(
|
||||
compare_3d<histogram<true, default_axes, adaptive_storage<>>>(
|
||||
4000000, itype));
|
||||
}
|
||||
|
||||
@@ -141,21 +180,21 @@ int main() {
|
||||
else
|
||||
printf("normal distribution\n");
|
||||
printf("hs_ss %.3f\n",
|
||||
compare_6d<static_histogram<
|
||||
compare_6d<histogram<false,
|
||||
mpl::vector<regular_axis<>, regular_axis<>, regular_axis<>,
|
||||
regular_axis<>, regular_axis<>, regular_axis<>>,
|
||||
container_storage<std::vector<int>>>>(2000000, itype));
|
||||
printf("hs_sd %.3f\n",
|
||||
compare_6d<static_histogram<
|
||||
compare_6d<histogram<false,
|
||||
mpl::vector<regular_axis<>, regular_axis<>, regular_axis<>,
|
||||
regular_axis<>, regular_axis<>, regular_axis<>>,
|
||||
adaptive_storage<>>>(2000000, itype));
|
||||
printf("hd_ss %.3f\n",
|
||||
compare_6d<dynamic_histogram<default_axes,
|
||||
compare_6d<histogram<true, default_axes,
|
||||
container_storage<std::vector<int>>>>(
|
||||
2000000, itype));
|
||||
printf("hd_sd %.3f\n",
|
||||
compare_6d<dynamic_histogram<default_axes, adaptive_storage<>>>(
|
||||
compare_6d<histogram<true, default_axes, adaptive_storage<>>>(
|
||||
2000000, itype));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user