// // immer: immutable data structures for C++ // Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente // // This software is distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt // #pragma once #include "benchmark/vector/common.hpp" namespace { template auto benchmark_drop() { return [] (nonius::chronometer meter) { auto n = meter.param(); auto v = Vektor{}; for (auto i = 0u; i < n; ++i) v = PushFn{}(std::move(v), i); measure(meter, [&] { for (auto i = 0u; i < n; ++i) v.drop(i); }); }; } template auto benchmark_drop_lin() { return [] (nonius::chronometer meter) { auto n = meter.param(); auto v = Vektor{}; for (auto i = 0u; i < n; ++i) v = PushFn{}(std::move(v), i); measure(meter, [&] { auto r = v; for (auto i = 0u; i < n; ++i) r = r.drop(1); return r; }); }; } template auto benchmark_drop_move() { return [] (nonius::chronometer meter) { auto n = meter.param(); auto v = Vektor{}; for (auto i = 0u; i < n; ++i) v = PushFn{}(std::move(v), i); measure(meter, [&] { auto r = v; for (auto i = 0u; i < n; ++i) r = std::move(r).drop(1); return r; }); }; } template auto benchmark_drop_mut() { return [] (nonius::chronometer meter) { auto n = meter.param(); auto vv = Vektor{}; for (auto i = 0u; i < n; ++i) vv = PushFn{}(std::move(vv), i); measure(meter, [&] { auto v = vv.transient(); for (auto i = 0u; i < n; ++i) v.drop(1); }); }; } template auto benchmark_drop_librrb(Fn make) { return [=] (nonius::chronometer meter) { auto n = meter.param(); auto v = make(n); measure(meter, [&] { for (auto i = 0u; i < n; ++i) rrb_slice(v, i, n); }); }; } template auto benchmark_drop_lin_librrb(Fn make) { return [=] (nonius::chronometer meter) { auto n = meter.param(); auto v = make(n); measure(meter, [&] { auto r = v; for (auto i = 0u; i < n; ++i) r = rrb_slice(r, 1, n); return r; }); }; } template auto benchmark_drop_mut_librrb(Fn make) { return [=] (nonius::chronometer meter) { auto n = meter.param(); auto v = make(n); measure(meter, [&] { auto r = rrb_to_transient(v); for (auto i = 0u; i < n; ++i) r = transient_rrb_slice(r, 1, n); return r; }); }; } } // anonymous namespace