just test BOOST_FOREACH not containers

This commit is contained in:
Andreas Fabri 2015-04-21 09:44:32 +02:00
parent 187f7e247d
commit 5454a9d057
2 changed files with 30 additions and 15 deletions

View File

@ -47,25 +47,27 @@ run(const G& g)
boost::rand48 random;
boost::random_number_generator<boost::rand48> rng(random);
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;
#if 0
t.start();
Map vm;
BOOST_FOREACH(vertex_descriptor vd, V){
vm[vd] = get(vpm,vd);
}
t.stop(); std::cerr << "Insertion: " << t.time() << " sec. " << std::endl;
#endif
Vector_3 v(0,0,0);
std::size_t st=0;
#if 0
std::cerr << "BOOST_FOREACH std::vector<vertex_descriptor)\n";
t.reset(); t.start();
for(int i=0; i<100; i++){
BOOST_FOREACH(vertex_descriptor vd, V2){
#ifdef NOHASH
v = v + (get(vpm,vd) - CGAL::ORIGIN);
st += std::size_t(vd);
#else
typename Map::iterator it = vm.find(vd);
v = v + ((*it).second - CGAL::ORIGIN);
@ -74,14 +76,19 @@ run(const G& g)
}
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
#endif
std::cerr << "BOOST_FOREACH boost::iterator_range r = vertices(g))\n";
t.reset(); t.start();
for(int i=0; i<100; i++){
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) {
#ifdef NOHASH
v = v + (get(vpm,vd) - CGAL::ORIGIN);
st += std::size_t(vd);
// v = v + (get(vpm,vd) - CGAL::ORIGIN);
#else
typename Map::iterator it = vm.find(vd);
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";
t.reset(); t.start();
for(int i=0; i<100; i++){
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) {
#ifdef NOHASH
v = v + (get(vpm,vd) - CGAL::ORIGIN);
#ifdef NOHASH
st += std::size_t(vd);
//v = v + (get(vpm,vd) - CGAL::ORIGIN);
#else
typename Map::iterator it = vm.find(vd);
v = v + ((*it).second - CGAL::ORIGIN);
@ -110,8 +118,9 @@ run(const G& g)
t.reset(); t.start();
for(int i=0; i<100; i++){
BOOST_FOREACH(vertex_descriptor vd, vertices(g)) {
#ifdef NOHASH
v = v + (get(vpm,vd) - CGAL::ORIGIN);
#ifdef NOHASH
st += std::size_t(vd);
//v = v + (get(vpm,vd) - CGAL::ORIGIN);
#else
typename Map::iterator it = vm.find(vd);
v = v + ((*it).second - CGAL::ORIGIN);
@ -120,6 +129,7 @@ run(const G& g)
}
t.stop(); std::cerr << " " <<t.time() << " sec. " << std::endl;
#if 0
std::cerr << "boost::tie(vb,ve) = vertices(g);\n";
t.reset(); t.start();
for(int i=0; i<100; i++){
@ -128,7 +138,8 @@ run(const G& g)
for(; vb != ve; ++vb) {
vertex_descriptor vd = *vb;
#ifdef NOHASH
v = v + (get(vpm,vd) - CGAL::ORIGIN);
st += std::size_t(vd);
//v = v + (get(vpm,vd) - CGAL::ORIGIN);
#else
typename Map::iterator it = vm.find(vd);
v = v + ((*it).second - CGAL::ORIGIN);
@ -137,7 +148,9 @@ run(const G& g)
}
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 << "\nSurface_mesh std::map"<< std::endl;
run<Mesh,SM>(m);
#if 0
std::cerr << "\nSurface_mesh std::unordered_map"<< std::endl;
run<Mesh,SUM>(m);
std::cerr << "\nSurface_mesh boost::unordered_map"<< std::endl;
run<Mesh,BUM>(m);
#endif
}
#if 1
#if 0
{
typedef CGAL::Polyhedron_3<Kernel> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;

View File

@ -140,7 +140,6 @@ public:
}
}while(true);
std::cerr << "|" << buffer.c_str() << "|" << std::endl;
if(sscanf(buffer.c_str(), "%lf", &t) != 1) {
// if a 'buffer' does not contain a double, set the fail bit.
is.setstate(std::ios_base::failbit);