diff --git a/bench/bench_alloc_expand_bwd.cpp b/bench/bench_alloc_expand_bwd.cpp index 7e2caa9..3a095ed 100644 --- a/bench/bench_alloc_expand_bwd.cpp +++ b/bench/bench_alloc_expand_bwd.cpp @@ -23,31 +23,11 @@ #include //assert #include + using boost::move_detail::cpu_timer; using boost::move_detail::cpu_times; using boost::move_detail::nanosecond_type; -namespace bc = boost::container; - -typedef std::allocator StdAllocator; -typedef bc::allocator AllocatorPlusV2Mask; -typedef bc::allocator AllocatorPlusV2; -typedef bc::allocator AllocatorPlusV1; - -template struct get_allocator_name; - -template<> struct get_allocator_name -{ static const char *get() { return "StdAllocator"; } }; - -template<> struct get_allocator_name -{ static const char *get() { return "AllocatorPlusV2Mask"; } }; - -template<> struct get_allocator_name -{ static const char *get() { return "AllocatorPlusV2"; } }; - -template<> struct get_allocator_name -{ static const char *get() { return "AllocatorPlusV1"; } }; - //typedef int MyInt; class MyInt @@ -89,6 +69,30 @@ struct has_trivial_destructor_after_move } //namespace boost{ +namespace bc = boost::container; + +typedef std::allocator StdAllocator; +typedef bc::allocator AllocatorPlusV2Mask; +typedef bc::allocator AllocatorPlusV2; +typedef bc::allocator AllocatorPlusV1; + +template struct get_allocator_name; + +template<> struct get_allocator_name +{ static const char *get() { return "StdAllocator"; } }; + +template<> struct get_allocator_name +{ static const char *get() { return "AllocatorPlusV2Mask"; } }; + +template<> struct get_allocator_name +{ static const char *get() { return "AllocatorPlusV2"; } }; + +template<> struct get_allocator_name +{ static const char *get() { return "AllocatorPlusV1"; } }; + + + + void print_header() { std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";" @@ -99,7 +103,7 @@ void print_header() template void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output) { - typedef typename Allocator::template rebind::other IntAllocator; + typedef Allocator IntAllocator; unsigned int numalloc = 0, numexpand = 0; cpu_timer timer; diff --git a/bench/bench_alloc_shrink_to_fit.cpp b/bench/bench_alloc_shrink_to_fit.cpp index aa65a54..c6840c9 100644 --- a/bench/bench_alloc_shrink_to_fit.cpp +++ b/bench/bench_alloc_shrink_to_fit.cpp @@ -31,21 +31,6 @@ using boost::move_detail::nanosecond_type; namespace bc = boost::container; -typedef std::allocator StdAllocator; -typedef bc::allocator AllocatorPlusV2; -typedef bc::allocator AllocatorPlusV1; - -template struct get_allocator_name; - -template<> struct get_allocator_name -{ static const char *get() { return "StdAllocator"; } }; - -template<> struct get_allocator_name -{ static const char *get() { return "AllocatorPlusV2"; } }; - -template<> struct get_allocator_name -{ static const char *get() { return "AllocatorPlusV1"; } }; - class MyInt { std::size_t int_; //Use a type that will grow on 64 bit machines @@ -64,6 +49,21 @@ class MyInt } }; +typedef std::allocator StdAllocator; +typedef bc::allocator AllocatorPlusV2; +typedef bc::allocator AllocatorPlusV1; + +template struct get_allocator_name; + +template<> struct get_allocator_name +{ static const char *get() { return "StdAllocator"; } }; + +template<> struct get_allocator_name +{ static const char *get() { return "AllocatorPlusV2"; } }; + +template<> struct get_allocator_name +{ static const char *get() { return "AllocatorPlusV1"; } }; + void print_header() { std::cout << "Allocator" << ";" << "Iterations" << ";" << "Size" << ";" @@ -73,7 +73,7 @@ void print_header() template void vector_test_template(unsigned int num_iterations, unsigned int num_elements, bool csv_output) { - typedef typename Allocator::template rebind::other IntAllocator; + typedef Allocator IntAllocator; unsigned int capacity = 0; const std::size_t Step = 5; diff --git a/bench/bench_alloc_stable_vector_burst.cpp b/bench/bench_alloc_stable_vector_burst.cpp index 9adda0b..89a54b8 100644 --- a/bench/bench_alloc_stable_vector_burst.cpp +++ b/bench/bench_alloc_stable_vector_burst.cpp @@ -34,11 +34,27 @@ using boost::move_detail::nanosecond_type; namespace bc = boost::container; -typedef std::allocator StdAllocator; -typedef bc::allocator AllocatorPlusV1; -typedef bc::allocator AllocatorPlusV2; +class MyInt +{ + int int_; + + public: + MyInt(int i = 0) : int_(i){} + MyInt(const MyInt &other) + : int_(other.int_) + {} + MyInt & operator=(const MyInt &other) + { + int_ = other.int_; + return *this; + } +}; + +typedef std::allocator StdAllocator; +typedef bc::allocator AllocatorPlusV1; +typedef bc::allocator AllocatorPlusV2; typedef bc::adaptive_pool - < int + < MyInt , bc::ADP_nodes_per_block , 0//bc::ADP_max_free_blocks , 2 @@ -58,27 +74,10 @@ template<> struct get_allocator_name template<> struct get_allocator_name { static const char *get() { return "AdPool2PercentV2"; } }; -class MyInt -{ - int int_; - - public: - MyInt(int i = 0) : int_(i){} - MyInt(const MyInt &other) - : int_(other.int_) - {} - MyInt & operator=(const MyInt &other) - { - int_ = other.int_; - return *this; - } -}; - template struct get_vector { - typedef bc::vector - ::other> type; + typedef bc::vector type; static const char *vector_name() { return "vector"; @@ -89,7 +88,7 @@ template struct get_stable_vector { typedef bc::stable_vector - ::other> type; + type; static const char *vector_name() { return "stable_vector";