mirror of
https://github.com/triqs/dft_tools
synced 2024-11-01 11:43:47 +01:00
b2603dcf3a
- add a workaround for a gcc issue in fisrt_include. - --> make sure that the first include is : either a triqs lib or first_include
33 lines
728 B
C++
33 lines
728 B
C++
#include <triqs/utility/first_include.hpp>
|
|
#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();
|
|
|
|
|
|
}
|