#include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef CGAL::Simple_cartesian Kernel; struct Point_3 : Kernel::Point_3 { using Kernel::Point_3::operator=; Point_3() : Kernel::Point_3(0,0,0) {} Point_3(int i) : Kernel::Point_3(i,0,0) {} }; typedef Kernel::Vector_3 Vector_3; typedef CGAL::Polyhedron_3 Mesh; typedef boost::property_map::type VPM; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef std::vector Vertex_list; typedef CGAL::Timer Timer; template auto reserve(Map& sm, typename Map::size_type ii) -> decltype(sm.reserve(ii), void()){ sm.reserve(ii); } template Point_3 lookup(Map& sm,vertex_descriptor vh){ auto search = sm.find(vh); if(search != sm.end()) return search->second; return Point_3(); } template Point_3 lookup(CGAL::Unique_hash_map& sm,vertex_descriptor vh){ const CGAL::Unique_hash_map& const_sm = sm; return const_sm[vh]; } template double fct(int ii, int jj, const Vertex_list& V, const Vertex_list& V2, const VPM& vpm, const std::string& s) { int x = 0; Timer construct, query, lookups; construct.start(); for(int j=0; j SM; typedef std::unordered_map SUM; typedef boost::unordered_map BUM; typedef CGAL::Unique_hash_map UHM; Mesh mesh1; VPM vpm1 = get(CGAL::vertex_point,mesh1); Vertex_list V1; random_mesh(ii,jj,mesh1,vpm1,V1); Mesh mesh2; VPM vpm2 = get(CGAL::vertex_point,mesh2); Vertex_list V2; random_mesh(ii,jj,mesh2,vpm2,V2); std::cerr << std::endl << ii << " items and queries (repeated " << jj << " times)" << std::endl; std::cerr << "Name\t\t\t| Version\t| Construction\t| Queries\t| Lookups" << std::endl; int temp; int res = fct(ii,jj, V1,V2, vpm1, "std::map\t\t|\t\t| " ); temp = fct(ii,jj,V1,V2, vpm1, "std::unordered_map\t|\t\t| " ); if(temp != res){ std::cout << temp << " != " << res << std::endl;} temp = fct(ii,jj, V1,V2, vpm1, "boost::unordered_map\t|\t\t| " ); if(temp != res){ std::cout << temp << " != " << res << std::endl;} temp = fct(ii,jj,V1,V2, vpm1, "CGAL::Unique_hash_map\t| master\t| " ); if(temp != res){ std::cout << temp << " != " << res << std::endl;} } int main(int , char* argv[]) { fct(1000000, 10); fct(100000, 100); fct(10000, 1000); fct(1000, 10000); fct(500, 20000); fct(250, 40000); fct(100, 100000); fct(10, 1000000); return 0; }