#include #include #include #include namespace { void devector_unsafe_push_back(benchmark::State& state) { while (state.KeepRunning()) { state.PauseTiming(); boost::double_ended::devector v(state.range(0), boost::double_ended::reserve_only_tag{}); state.ResumeTiming(); for (int j = 0; j < state.range(0); ++j) { v.unsafe_push_back(j); } } } BENCHMARK(devector_unsafe_push_back)->Range(8, 8<<12); void vector_push_back(benchmark::State& state) { while (state.KeepRunning()) { state.PauseTiming(); std::vector v; v.reserve(state.range(0)); state.ResumeTiming(); for (int j = 0; j < state.range(0); ++j) { v.push_back(j); } } } BENCHMARK(vector_push_back)->Range(8, 8<<12); void cvector_push_back(benchmark::State& state) { while (state.KeepRunning()) { state.PauseTiming(); boost::container::vector v; v.reserve(state.range(0)); state.ResumeTiming(); for (int j = 0; j < state.range(0); ++j) { v.push_back(j); } } } BENCHMARK(cvector_push_back)->Range(8, 8<<12); } BENCHMARK_MAIN();