diff --git a/benchmark/test_array_allocation.cpp b/benchmark/test_array_allocation.cpp index c87630466..04615747f 100644 --- a/benchmark/test_array_allocation.cpp +++ b/benchmark/test_array_allocation.cpp @@ -4,6 +4,7 @@ #include #include #include +#include // http://stackoverflow.com/questions/17347254/why-is-allocation-and-deallocation-of-stdvector-slower-than-dynamic-array-on-m @@ -228,7 +229,7 @@ public: void operator()() const { for (std::size_t i=0;i data(size_,0); + std::valarray data(static_cast(0),static_cast(size_)); + ensure_zero(&data[0],size_); + } + } +}; + +// http://i42.co.uk/stuff/vecarray.htm +// http://www.boost.org/doc/libs/1_54_0/doc/html/boost/container/static_vector.html + +class test7 : public benchmark::test_case +{ +public: + uint32_t size_; + std::vector array_; + test7(mapnik::parameters const& params) + : test_case(params), + size_(*params.get("size",256*256)), + array_(size_,0) { } + bool validate() const + { + return true; + } + void operator()() const + { + for (std::size_t i=0;i data(size_,0); ensure_zero(&data[0],size_); } } @@ -299,12 +325,16 @@ int main(int argc, char** argv) run(test_runner,"std::string range"); } { - test5 test_runner(params); + test5b test_runner(params); run(test_runner,"std::string &[0]"); } { - test5 test_runner(params); + test6 test_runner(params); run(test_runner,"valarray"); } + { + test7 test_runner(params); + run(test_runner,"static_vector"); + } return 0; }