mirror of https://github.com/CGAL/cgal
just test BOOST_FOREACH not containers
This commit is contained in:
parent
187f7e247d
commit
5454a9d057
|
|
@ -47,25 +47,27 @@ run(const G& g)
|
||||||
boost::rand48 random;
|
boost::rand48 random;
|
||||||
boost::random_number_generator<boost::rand48> rng(random);
|
boost::random_number_generator<boost::rand48> rng(random);
|
||||||
std::random_shuffle(V.begin(), V.end(), rng);
|
std::random_shuffle(V.begin(), V.end(), rng);
|
||||||
for(int i=0; i < 10; i++){
|
|
||||||
std::cerr << get(vpm,V[i]) << std::endl;
|
|
||||||
}
|
|
||||||
Timer t;
|
Timer t;
|
||||||
|
#if 0
|
||||||
t.start();
|
t.start();
|
||||||
Map vm;
|
Map vm;
|
||||||
BOOST_FOREACH(vertex_descriptor vd, V){
|
BOOST_FOREACH(vertex_descriptor vd, V){
|
||||||
vm[vd] = get(vpm,vd);
|
vm[vd] = get(vpm,vd);
|
||||||
}
|
}
|
||||||
t.stop(); std::cerr << "Insertion: " << t.time() << " sec. " << std::endl;
|
t.stop(); std::cerr << "Insertion: " << t.time() << " sec. " << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
Vector_3 v(0,0,0);
|
Vector_3 v(0,0,0);
|
||||||
|
std::size_t st=0;
|
||||||
|
|
||||||
|
#if 0
|
||||||
std::cerr << "BOOST_FOREACH std::vector<vertex_descriptor)\n";
|
std::cerr << "BOOST_FOREACH std::vector<vertex_descriptor)\n";
|
||||||
t.reset(); t.start();
|
t.reset(); t.start();
|
||||||
for(int i=0; i<100; i++){
|
for(int i=0; i<100; i++){
|
||||||
BOOST_FOREACH(vertex_descriptor vd, V2){
|
BOOST_FOREACH(vertex_descriptor vd, V2){
|
||||||
#ifdef NOHASH
|
#ifdef NOHASH
|
||||||
v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
st += std::size_t(vd);
|
||||||
#else
|
#else
|
||||||
typename Map::iterator it = vm.find(vd);
|
typename Map::iterator it = vm.find(vd);
|
||||||
v = v + ((*it).second - CGAL::ORIGIN);
|
v = v + ((*it).second - CGAL::ORIGIN);
|
||||||
|
|
@ -74,14 +76,19 @@ run(const G& g)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
|
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
std::cerr << "BOOST_FOREACH boost::iterator_range r = vertices(g))\n";
|
std::cerr << "BOOST_FOREACH boost::iterator_range r = vertices(g))\n";
|
||||||
|
|
||||||
t.reset(); t.start();
|
t.reset(); t.start();
|
||||||
for(int i=0; i<100; i++){
|
|
||||||
boost::iterator_range<typename boost::graph_traits<G>::vertex_iterator> r = vertices(g);
|
boost::iterator_range<typename boost::graph_traits<G>::vertex_iterator> r = vertices(g);
|
||||||
|
for(int i=0; i<100; i++){
|
||||||
|
|
||||||
BOOST_FOREACH(vertex_descriptor vd, r) {
|
BOOST_FOREACH(vertex_descriptor vd, r) {
|
||||||
#ifdef NOHASH
|
#ifdef NOHASH
|
||||||
v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
st += std::size_t(vd);
|
||||||
|
// v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
||||||
#else
|
#else
|
||||||
typename Map::iterator it = vm.find(vd);
|
typename Map::iterator it = vm.find(vd);
|
||||||
v = v + ((*it).second - CGAL::ORIGIN);
|
v = v + ((*it).second - CGAL::ORIGIN);
|
||||||
|
|
@ -93,11 +100,12 @@ run(const G& g)
|
||||||
|
|
||||||
std::cerr << "BOOST_FOREACH CGAL::Iterator_range r = vertices(g))\n";
|
std::cerr << "BOOST_FOREACH CGAL::Iterator_range r = vertices(g))\n";
|
||||||
t.reset(); t.start();
|
t.reset(); t.start();
|
||||||
for(int i=0; i<100; i++){
|
|
||||||
CGAL::Iterator_range<typename boost::graph_traits<G>::vertex_iterator> ir = vertices(g);
|
CGAL::Iterator_range<typename boost::graph_traits<G>::vertex_iterator> ir = vertices(g);
|
||||||
|
for(int i=0; i<100; i++){
|
||||||
BOOST_FOREACH(vertex_descriptor vd, ir) {
|
BOOST_FOREACH(vertex_descriptor vd, ir) {
|
||||||
#ifdef NOHASH
|
#ifdef NOHASH
|
||||||
v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
st += std::size_t(vd);
|
||||||
|
//v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
||||||
#else
|
#else
|
||||||
typename Map::iterator it = vm.find(vd);
|
typename Map::iterator it = vm.find(vd);
|
||||||
v = v + ((*it).second - CGAL::ORIGIN);
|
v = v + ((*it).second - CGAL::ORIGIN);
|
||||||
|
|
@ -111,7 +119,8 @@ run(const G& g)
|
||||||
for(int i=0; i<100; i++){
|
for(int i=0; i<100; i++){
|
||||||
BOOST_FOREACH(vertex_descriptor vd, vertices(g)) {
|
BOOST_FOREACH(vertex_descriptor vd, vertices(g)) {
|
||||||
#ifdef NOHASH
|
#ifdef NOHASH
|
||||||
v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
st += std::size_t(vd);
|
||||||
|
//v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
||||||
#else
|
#else
|
||||||
typename Map::iterator it = vm.find(vd);
|
typename Map::iterator it = vm.find(vd);
|
||||||
v = v + ((*it).second - CGAL::ORIGIN);
|
v = v + ((*it).second - CGAL::ORIGIN);
|
||||||
|
|
@ -120,6 +129,7 @@ run(const G& g)
|
||||||
}
|
}
|
||||||
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
|
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
|
||||||
|
|
||||||
|
#if 0
|
||||||
std::cerr << "boost::tie(vb,ve) = vertices(g);\n";
|
std::cerr << "boost::tie(vb,ve) = vertices(g);\n";
|
||||||
t.reset(); t.start();
|
t.reset(); t.start();
|
||||||
for(int i=0; i<100; i++){
|
for(int i=0; i<100; i++){
|
||||||
|
|
@ -128,7 +138,8 @@ run(const G& g)
|
||||||
for(; vb != ve; ++vb) {
|
for(; vb != ve; ++vb) {
|
||||||
vertex_descriptor vd = *vb;
|
vertex_descriptor vd = *vb;
|
||||||
#ifdef NOHASH
|
#ifdef NOHASH
|
||||||
v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
st += std::size_t(vd);
|
||||||
|
//v = v + (get(vpm,vd) - CGAL::ORIGIN);
|
||||||
#else
|
#else
|
||||||
typename Map::iterator it = vm.find(vd);
|
typename Map::iterator it = vm.find(vd);
|
||||||
v = v + ((*it).second - CGAL::ORIGIN);
|
v = v + ((*it).second - CGAL::ORIGIN);
|
||||||
|
|
@ -137,7 +148,9 @@ run(const G& g)
|
||||||
}
|
}
|
||||||
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
|
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
|
||||||
|
|
||||||
std::cerr << "v = " << v << std::endl;
|
#endif
|
||||||
|
|
||||||
|
std::cerr << "v = " << v << " " << st << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,12 +175,15 @@ int main(int , char* argv[])
|
||||||
std::cerr << num_vertices(m) << " items\n";
|
std::cerr << num_vertices(m) << " items\n";
|
||||||
std::cerr << "\nSurface_mesh std::map"<< std::endl;
|
std::cerr << "\nSurface_mesh std::map"<< std::endl;
|
||||||
run<Mesh,SM>(m);
|
run<Mesh,SM>(m);
|
||||||
|
#if 0
|
||||||
std::cerr << "\nSurface_mesh std::unordered_map"<< std::endl;
|
std::cerr << "\nSurface_mesh std::unordered_map"<< std::endl;
|
||||||
run<Mesh,SUM>(m);
|
run<Mesh,SUM>(m);
|
||||||
std::cerr << "\nSurface_mesh boost::unordered_map"<< std::endl;
|
std::cerr << "\nSurface_mesh boost::unordered_map"<< std::endl;
|
||||||
run<Mesh,BUM>(m);
|
run<Mesh,BUM>(m);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#if 1
|
|
||||||
|
#if 0
|
||||||
{
|
{
|
||||||
typedef CGAL::Polyhedron_3<Kernel> Mesh;
|
typedef CGAL::Polyhedron_3<Kernel> Mesh;
|
||||||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,6 @@ public:
|
||||||
}
|
}
|
||||||
}while(true);
|
}while(true);
|
||||||
|
|
||||||
std::cerr << "|" << buffer.c_str() << "|" << std::endl;
|
|
||||||
if(sscanf(buffer.c_str(), "%lf", &t) != 1) {
|
if(sscanf(buffer.c_str(), "%lf", &t) != 1) {
|
||||||
// if a 'buffer' does not contain a double, set the fail bit.
|
// if a 'buffer' does not contain a double, set the fail bit.
|
||||||
is.setstate(std::ios_base::failbit);
|
is.setstate(std::ios_base::failbit);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue