also benchmark bost:container::deque

This commit is contained in:
Andreas Fabri 2014-12-12 09:45:17 +01:00
parent 1bc624ee30
commit 6adece5ee9
2 changed files with 33 additions and 9 deletions

View File

@ -4,35 +4,49 @@
#include <CGAL/array.h>
#include <CGAL/Block_list.h>
#include <CGAL/Timer.h>
#include <boost/container/deque.hpp>
#if 1 //
// leaf
struct X {
double a,b,c,d,e,f,g,h,i,j,k,l;
bool b;
int i;
double d1;
};
#else
// internal
struct X {
bool b;
int i;
double d1, d2, d3, d4,d5;
};
#endif
int main()
{
CGAL::Memory_sizer ms;
CGAL::Timer t;
char c;
t.start();
#if 0
std::cout <<"blocklist"<< std::endl;
CGAL::Block_list<X, 256> de;
#elif 1
#elif 0
std::cout <<"boost::container::deque"<< std::endl;
boost::container::deque<X> de;
#elif 0
std::cout <<"std::deque"<< std::endl;
std::deque<X> de;
#else
std::cout <<"vector"<< std::endl;
std::vector<X> de;
de.reserve(100000000);
// de.reserve(100000000);
#endif
for(int i=0; i < 100000000; i++){
for(int i=0; i < 10000000; i++){
de.push_back(X());
}
t.stop();
std::cout << t.time() << "sec"<< std::endl;
std::cout << ms.virtual_size() << " " << ms.resident_size() << std::endl;
std::cout << "cont>" << std::endl;
std::cin >> c;
return 0;
}

View File

@ -12,12 +12,20 @@ namespace CGAL {
typedef CGAL::cpp11::array<T,N> Block;
int index;
std::list<Block> blocks;
typedef typename std::list<Block>::iterator List_iterator;
typedef typename Block::iterator Block_iterator;
public:
Block_list()
: index(N)
{}
std::size_t size() const
{
return (index == N)? (blocks.size()*N) : ((blocks.size()-1)*N+index);
}
T* push_back(const T& t)
{
if(index==N){
@ -32,6 +40,8 @@ namespace CGAL {
return ptr;
}
void clear()
{
blocks.clear();