summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/benchmark
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-09-17 20:58:41 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-09-17 20:58:41 +0000
commit9ded4522e4be2b018172c0563b2acf9d5cdc5b44 (patch)
treea691f1fa0817ad20f999d2437d2af9a2f70a11d8 /src/Alpha_complex/benchmark
parente618887f6bed9dbfc36bb6a7c6174a83bb2dd68e (diff)
Add benchmark
Safe version for Alpha complex 3d (missing part if not weighted and not periodic) Need to fix Alpha_complex_3d_unit_test git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3893 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 304c9f89826008eab67a72f3742caa8d6d80f36b
Diffstat (limited to 'src/Alpha_complex/benchmark')
-rw-r--r--src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp162
-rw-r--r--src/Alpha_complex/benchmark/CMakeLists.txt9
2 files changed, 171 insertions, 0 deletions
diff --git a/src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp b/src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp
new file mode 100644
index 00000000..18802ee5
--- /dev/null
+++ b/src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp
@@ -0,0 +1,162 @@
+#include <gudhi/Alpha_complex_3d.h>
+// to construct a simplex_tree from alpha complex
+#include <gudhi/Simplex_tree.h>
+#include <gudhi/random_point_generators.h>
+#include <gudhi/Clock.h>
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <limits> // for numeric limits
+
+#include <CGAL/Epick_d.h>
+#include <CGAL/Random.h>
+
+template <typename Alpha_complex_3d>
+void benchmark_points_on_torus_3D(const std::string& msg ) {
+ using K = CGAL::Epick_d< CGAL::Dimension_tag<3> >;
+ std::cout << msg << std::endl;
+ for (int nb_points = 1000; nb_points <= /*12*/5000 ; nb_points *= 5) {
+ std::cout << "### Alpha complex 3d on torus with " << nb_points << " points." << std::endl;
+ std::vector<K::Point_d> points_on_torus = Gudhi::generate_points_on_torus_3D<K>(nb_points, 1.0, 0.5);
+ std::vector<typename Alpha_complex_3d::Point_3> points;
+
+ for(auto p:points_on_torus) {
+ points.push_back(typename Alpha_complex_3d::Point_3(p[0],p[1],p[2]));
+ }
+
+ Gudhi::Clock ac_create_clock("benchmark_points_on_torus_3D - Alpha complex 3d creation"); ac_create_clock.begin();
+ Alpha_complex_3d alpha_complex_from_points(points);
+ ac_create_clock.end(); std::cout << ac_create_clock;
+
+ Gudhi::Simplex_tree<> simplex;
+ Gudhi::Clock st_create_clock("benchmark_points_on_torus_3D - simplex tree creation"); st_create_clock.begin();
+ alpha_complex_from_points.create_complex(simplex);
+ st_create_clock.end(); std::cout << st_create_clock;
+ }
+
+}
+
+template <typename Weighted_alpha_complex_3d>
+void benchmark_weighted_points_on_torus_3D(const std::string& msg ) {
+ using K = CGAL::Epick_d< CGAL::Dimension_tag<3> >;
+
+ CGAL::Random random(8);
+
+ std::cout << msg << std::endl;
+ for (int nb_points = 1000; nb_points <= 125000 ; nb_points *= 5) {
+ std::cout << "### Alpha complex 3d on torus with " << nb_points << " points." << std::endl;
+ std::vector<K::Point_d> points_on_torus = Gudhi::generate_points_on_torus_3D<K>(nb_points, 1.0, 0.5);
+
+ using Point = typename Weighted_alpha_complex_3d::Point_3;
+ using Weighted_point = typename Weighted_alpha_complex_3d::Triangulation_3::Weighted_point;
+
+ std::vector<Weighted_point> points;
+
+ for(auto p:points_on_torus) {
+ points.push_back(Weighted_point(Point(p[0],p[1],p[2]), 0.9 + random.get_double(0., 0.01)));
+ }
+
+ Gudhi::Clock ac_create_clock("benchmark_weighted_points_on_torus_3D - Alpha complex 3d creation"); ac_create_clock.begin();
+ Weighted_alpha_complex_3d alpha_complex_from_points(points);
+ ac_create_clock.end(); std::cout << ac_create_clock;
+
+ Gudhi::Simplex_tree<> simplex;
+ Gudhi::Clock st_create_clock("benchmark_weighted_points_on_torus_3D - simplex tree creation"); st_create_clock.begin();
+ alpha_complex_from_points.create_complex(simplex);
+ st_create_clock.end(); std::cout << st_create_clock;
+ }
+
+}
+
+template <typename Periodic_alpha_complex_3d>
+void benchmark_periodic_points(const std::string& msg ) {
+ std::cout << msg << std::endl;
+ for (double nb_points = 10.; nb_points <= 40. ; nb_points += 10.) {
+ std::cout << "### Periodic alpha complex 3d with " << nb_points*nb_points*nb_points << " points." << std::endl;
+ using Point = typename Periodic_alpha_complex_3d::Point_3;
+ std::vector<Point> points;
+
+ for (double i = 0; i < nb_points; i++) {
+ for (double j = 0; j < nb_points; j++) {
+ for (double k = 0; k < nb_points; k++) {
+ points.push_back(Point(i,j,k));
+ }
+ }
+ }
+
+ Gudhi::Clock ac_create_clock("benchmark_periodic_points - Alpha complex 3d creation"); ac_create_clock.begin();
+ Periodic_alpha_complex_3d alpha_complex_from_points(points, 0., 0., 0., nb_points, nb_points, nb_points);
+ ac_create_clock.end(); std::cout << ac_create_clock;
+
+ Gudhi::Simplex_tree<> simplex;
+ Gudhi::Clock st_create_clock("benchmark_periodic_points - simplex tree creation"); st_create_clock.begin();
+ alpha_complex_from_points.create_complex(simplex);
+ st_create_clock.end(); std::cout << st_create_clock;
+ }
+
+}
+
+template <typename Weighted_periodic_alpha_complex_3d>
+void benchmark_weighted_periodic_points(const std::string& msg ) {
+ std::cout << msg << std::endl;
+ CGAL::Random random(8);
+
+ for (double nb_points = 10.; nb_points <= 40. ; nb_points += 10.) {
+ std::cout << "### Weighted periodic alpha complex 3d with " << nb_points*nb_points*nb_points << " points." << std::endl;
+
+ using Point = typename Weighted_periodic_alpha_complex_3d::Point_3;
+ using Weighted_point = typename Weighted_periodic_alpha_complex_3d::Triangulation_3::Weighted_point;
+ std::vector<Weighted_point> points;
+
+ for (double i = 0; i < nb_points; i++) {
+ for (double j = 0; j < nb_points; j++) {
+ for (double k = 0; k < nb_points; k++) {
+ points.push_back(Weighted_point(Point(i,j,k), random.get_double(0., (nb_points*nb_points)/64.)));
+ }
+ }
+ }
+
+ Gudhi::Clock ac_create_clock("benchmark_weighted_periodic_points - Alpha complex 3d creation"); ac_create_clock.begin();
+ Weighted_periodic_alpha_complex_3d alpha_complex_from_points(points, 0., 0., 0., nb_points, nb_points, nb_points);
+ ac_create_clock.end(); std::cout << ac_create_clock;
+
+ Gudhi::Simplex_tree<> simplex;
+ Gudhi::Clock st_create_clock("benchmark_weighted_periodic_points - simplex tree creation"); st_create_clock.begin();
+ alpha_complex_from_points.create_complex(simplex);
+ st_create_clock.end(); std::cout << st_create_clock;
+ }
+
+}
+
+int main(int argc, char **argv) {
+ /*
+ benchmark_points_on_torus_3D<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::fast,
+ false, false>>("### Fast version");
+ benchmark_points_on_torus_3D<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::safe,
+ false, false>>("### Safe version");
+ benchmark_points_on_torus_3D<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::exact,
+ false, false>>("### Exact version");
+
+ benchmark_weighted_points_on_torus_3D<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::fast,
+ true, false>>("### Fast version");
+ benchmark_weighted_points_on_torus_3D<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::safe,
+ true, false>>("### Safe version");
+ benchmark_weighted_points_on_torus_3D<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::exact,
+ true, false>>("### Exact version");
+ */
+ benchmark_periodic_points<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::fast,
+ false, true>>("### Fast version");
+ benchmark_periodic_points<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::safe,
+ false, true>>("### Safe version");
+ benchmark_periodic_points<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::exact,
+ false, true>>("### Exact version");
+
+ benchmark_weighted_periodic_points<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::fast,
+ true, true>>("### Fast version");
+ benchmark_weighted_periodic_points<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::safe,
+ true, true>>("### Safe version");
+ benchmark_weighted_periodic_points<Gudhi::alpha_complex::Alpha_complex_3d<Gudhi::alpha_complex::complexity::exact,
+ true, true>>("### Exact version");
+ return 0;
+}
diff --git a/src/Alpha_complex/benchmark/CMakeLists.txt b/src/Alpha_complex/benchmark/CMakeLists.txt
new file mode 100644
index 00000000..622963dc
--- /dev/null
+++ b/src/Alpha_complex/benchmark/CMakeLists.txt
@@ -0,0 +1,9 @@
+project(Alpha_complex_benchmark)
+
+if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0)
+ add_executable(Alpha_complex_3d_benchmark Alpha_complex_3d_benchmark.cpp)
+ target_link_libraries(Alpha_complex_3d_benchmark ${CGAL_LIBRARY})
+ if (TBB_FOUND)
+ target_link_libraries(Alpha_complex_3d_benchmark ${TBB_LIBRARIES})
+ endif()
+endif ()