]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/container/bench/bench_alloc_expand_fwd.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / container / bench / bench_alloc_expand_fwd.cpp
index 4fc5c617c459fc8f5972bfe3144d70cb8aed94aa..f970e542928b37fa41ed3fbb9d16ab2f4ea2dcfb 100644 (file)
@@ -85,15 +85,15 @@ class MyInt
 };
 
 template<class Container>
-void vector_test_template(unsigned int num_iterations, unsigned int num_elements)
+void vector_test_template(std::size_t num_iterations, std::size_t num_elements)
 {
-   unsigned int numalloc = 0, numexpand = 0;
+   std::size_t numalloc = 0, numexpand = 0;
 
    cpu_timer timer;
    timer.resume();
 
-   unsigned int capacity = 0;
-   for(unsigned int r = 0; r != num_iterations; ++r){
+   std::size_t capacity = 0;
+   for(std::size_t r = 0; r != num_iterations; ++r){
       Container v;
       #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
          reset_alloc_stats(v);
@@ -101,47 +101,47 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
       //v.reserve(num_elements);
       //MyInt a[3];
 /*
-      for(unsigned int e = 0; e != num_elements/3; ++e){
+      for(std::size_t e = 0; e != num_elements/3; ++e){
          v.insert(v.end(), &a[0], &a[0]+3);
       }*/
 /*
-      for(unsigned int e = 0; e != num_elements/3; ++e){
-         v.insert(v.end(), 3, MyInt(e));
+      for(std::size_t e = 0; e != num_elements/3; ++e){
+         v.insert(v.end(), 3, MyInt((int)e));
       }*/
 /*
-      for(unsigned int e = 0; e != num_elements/3; ++e){
+      for(std::size_t e = 0; e != num_elements/3; ++e){
          v.insert(v.empty() ? v.end() : --v.end(), &a[0], &a[0]+3);
       }*/
 /*
-      for(unsigned int e = 0; e != num_elements/3; ++e){
-         v.insert(v.empty() ? v.end() : --v.end(), 3, MyInt(e));
+      for(std::size_t e = 0; e != num_elements/3; ++e){
+         v.insert(v.empty() ? v.end() : --v.end(), 3, MyInt((int)e));
       }*/
 /*
-      for(unsigned int e = 0; e != num_elements/3; ++e){
+      for(std::size_t e = 0; e != num_elements/3; ++e){
          v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), &a[0], &a[0]+3);
       }*/
 /*
-      for(unsigned int e = 0; e != num_elements/3; ++e){
-         v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), 3, MyInt(e));
+      for(std::size_t e = 0; e != num_elements/3; ++e){
+         v.insert(v.size() >= 3 ? v.end()-3 : v.begin(), 3, MyInt((int)e));
       }*/
 /*
-      for(unsigned int e = 0; e != num_elements; ++e){
-         v.insert(v.end(), MyInt(e));
+      for(std::size_t e = 0; e != num_elements; ++e){
+         v.insert(v.end(), MyInt((int)e));
       }*/
 /*
-      for(unsigned int e = 0; e != num_elements; ++e){
-         v.insert(v.empty() ? v.end() : --v.end(), MyInt(e));
+      for(std::size_t e = 0; e != num_elements; ++e){
+         v.insert(v.empty() ? v.end() : --v.end(), MyInt((int)e));
       }*/
 
-      for(unsigned int e = 0; e != num_elements; ++e){
-         v.push_back(MyInt(e));
+      for(std::size_t e = 0; e != num_elements; ++e){
+         v.push_back(MyInt((int)e));
       }
 
       #ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
          numalloc  += get_num_alloc(v);
          numexpand += get_num_expand(v);
       #endif
-      capacity = static_cast<unsigned int>(v.capacity());
+      capacity = static_cast<std::size_t>(v.capacity());
    }
 
    timer.stop();
@@ -151,12 +151,12 @@ void vector_test_template(unsigned int num_iterations, unsigned int num_elements
                << "Allocator: " << typeid(typename Container::allocator_type).name()
                << std::endl
                << "  push_back ns:              "
-               << float(nseconds)/(num_iterations*num_elements)
+               << float(nseconds)/float(num_iterations*num_elements)
                << std::endl
                << "  capacity  -  alloc calls (new/expand):  "
-                  << (unsigned int)capacity << "  -  "
-                  << (float(numalloc) + float(numexpand))/num_iterations
-                  << "(" << float(numalloc)/num_iterations << "/" << float(numexpand)/num_iterations << ")"
+                  << (std::size_t)capacity << "  -  "
+                  << (float(numalloc) + float(numexpand))/float(num_iterations)
+                  << "(" << float(numalloc)/float(num_iterations) << "/" << float(numexpand)/float(num_iterations) << ")"
                << std::endl << std::endl;
    bc::dlmalloc_trim(0);
 }
@@ -184,15 +184,15 @@ int main()
       std::size_t numele [] = { 10000 };
    #else
       #ifdef NDEBUG
-      unsigned int numit []  = { 1000, 10000, 100000, 1000000 };
+      std::size_t numit []  = { 1000, 10000, 100000, 1000000 };
       #else
-      unsigned int numit []  = { 100, 1000, 10000, 100000 };
+      std::size_t numit []  = { 100, 1000, 10000, 100000 };
       #endif
-      unsigned int numele [] = { 10000, 1000,   100,     10       };
+      std::size_t numele [] = { 10000, 1000,   100,     10       };
    #endif
 
    print_header();
-   for(unsigned int i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
+   for(std::size_t i = 0; i < sizeof(numele)/sizeof(numele[0]); ++i){
       vector_test_template< bc::vector<MyInt, std::allocator<MyInt> > >(numit[i], numele[i]);
       vector_test_template< bc::vector<MyInt, bc::allocator<MyInt, 1> > >(numit[i], numele[i]);
       vector_test_template<bc::vector<MyInt, bc::allocator<MyInt, 2, bc::expand_bwd | bc::expand_fwd> > >(numit[i], numele[i]);