3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 11:43:47 +01:00
dft_tools/test/speed/pool.cpp
Olivier Parcollet f2c7d449cc First commit : triqs libs version 1.0 alpha1
for earlier commits, see TRIQS0.x repository.
2013-07-17 19:24:07 +02:00

32 lines
685 B
C++

#include <vector>
#include <map>
#include <boost/pool/pool_alloc.hpp>
#include <ctime>
#include <iostream>
struct A {
double x; int i;
};
typedef std::map< double, A, std::less<double>, boost::fast_pool_allocator< std::pair<const double, A >>> m_t;
template<typename M> void test(M & m) {
std::clock_t start = std::clock() ;
for( int i = 0 ; i<100000 ; ++i ) {m.insert(std::make_pair( 10000*std::cos(i),A{0.5,i}));}
std::cout << ( std::clock() - start ) / double(CLOCKS_PER_SEC) << " secs.\n" ;
}
int main()
{
m_t m;
test(m);
std::map<double,A> m2;
test(m2);
boost::singleton_pool<boost::pool_allocator_tag, sizeof(std::pair<const double, A>)>::release_memory();
}