diff options
author | Vincent Ambo <mail@tazj.in> | 2020-12-23T12·36+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-12-23T12·44+0000 |
commit | 73e9265f954528b6b2eccf98572e77126539a8df (patch) | |
tree | 48a1e093761e86c5e605d074e8c4d5f1bb64f1b1 /third_party/immer/benchmark/extra | |
parent | f7ea650142eb796eb3f2827c805cc0bc563e2183 (diff) |
chore(3p/immer): Remove vendored copy of immer r/2029
We ended up dropping the use of this library again. Change-Id: I2c44cd22a6128d23f87a582402bf5fb84991d608 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2292 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'third_party/immer/benchmark/extra')
-rw-r--r-- | third_party/immer/benchmark/extra/refcounting.cpp | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/third_party/immer/benchmark/extra/refcounting.cpp b/third_party/immer/benchmark/extra/refcounting.cpp deleted file mode 100644 index c7c5183e6264..000000000000 --- a/third_party/immer/benchmark/extra/refcounting.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -// 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 -// - -#include <immer/detail/ref_count_base.hpp> - -#include <nonius.h++> -#include <boost/intrusive_ptr.hpp> - -#include <atomic> -#include <cstdlib> -#include <iterator> -#include <memory> -#include <utility> -#include <array> -#include <vector> - -NONIUS_PARAM(N, std::size_t{1000}) - -constexpr auto benchmark_size = 32u; - -struct object_t : immer::detail::ref_count_base<object_t> -{}; - -auto make_data() -{ - auto objs = std::array<std::unique_ptr<object_t>, benchmark_size>(); - std::generate(objs.begin(), objs.end(), [] { - return std::make_unique<object_t>(); - }); - auto refs = std::array<object_t*, benchmark_size>(); - std::transform(objs.begin(), objs.end(), refs.begin(), [](auto& obj) { - return obj.get(); - }); - return make_pair(std::move(objs), - std::move(refs)); -} - -NONIUS_BENCHMARK("intrusive_ptr", [] (nonius::chronometer meter) -{ - auto arr = std::array<boost::intrusive_ptr<object_t>, benchmark_size>{}; - auto storage = std::vector< - nonius::storage_for< - std::array<boost::intrusive_ptr<object_t>, benchmark_size>>> ( - meter.runs()); - std::generate(arr.begin(), arr.end(), [] { - return new object_t{}; - }); - meter.measure([&] (int i) { - storage[i].construct(arr); - }); -}) - -NONIUS_BENCHMARK("generic", [] (nonius::chronometer meter) -{ - auto data = make_data(); - auto& refs = data.second; - object_t* r[benchmark_size]; - - meter.measure([&] { - std::transform(refs.begin(), refs.end(), r, [] (auto& p) { - if (p) p->ref_count.fetch_add(1, std::memory_order_relaxed); - return p; - }); - return r; - }); -}) - -NONIUS_BENCHMARK("manual", [] (nonius::chronometer meter) -{ - auto data = make_data(); - auto& refs = data.second; - object_t* r[benchmark_size]; - - meter.measure([&] { - for (auto& p : refs) - if (p) p->ref_count.fetch_add(1, std::memory_order_relaxed); - std::copy(refs.begin(), refs.end(), r); - return r; - }); -}) - -NONIUS_BENCHMARK("manual - unroll", [] (nonius::chronometer meter) -{ - auto data = make_data(); - auto& refs = data.second; - object_t* r[benchmark_size]; - - meter.measure([&] { - auto e = refs.end(); - for (auto p = refs.begin(); p != e;) { - (*p++)->ref_count.fetch_add(1, std::memory_order_relaxed); - (*p++)->ref_count.fetch_add(1, std::memory_order_relaxed); - (*p++)->ref_count.fetch_add(1, std::memory_order_relaxed); - (*p++)->ref_count.fetch_add(1, std::memory_order_relaxed); - } - std::copy(refs.begin(), refs.end(), r); - return r; - }); -}) - -NONIUS_BENCHMARK("manual - nocheck", [] (nonius::chronometer meter) -{ - auto data = make_data(); - auto& refs = data.second; - object_t* r[benchmark_size]; - - meter.measure([&] { - for (auto& p : refs) - p->ref_count.fetch_add(1, std::memory_order_relaxed); - std::copy(refs.begin(), refs.end(), r); - return r; - }); -}) - -NONIUS_BENCHMARK("manual - constant", [] (nonius::chronometer meter) -{ - auto data = make_data(); - auto& refs = data.second; - object_t* r[benchmark_size]; - - meter.measure([&] { - for (auto i = 0u; i < benchmark_size; ++i) - refs[i]->ref_count.fetch_add(1, std::memory_order_relaxed); - std::copy(refs.begin(), refs.end(), r); - return r; - }); -}) - -NONIUS_BENCHMARK("manual - memcopy", [] (nonius::chronometer meter) -{ - auto data = make_data(); - auto& refs = data.second; - object_t* r[benchmark_size]; - - meter.measure([&] { - for (auto& p : refs) - if (p) p->ref_count.fetch_add(1, std::memory_order_relaxed); - std::memcpy(r, &refs[0], sizeof(object_t*) * benchmark_size); - return r; - }); -}) |