// Copyright 2022 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source // License, and you may not use this file except in compliance with the Business Source License. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. #include #include #include #include #include #include #include #include #include #include #include #include #include "storage/v3/key_store.hpp" #include "storage/v3/mvcc.hpp" #include "storage/v3/property_value.hpp" #include "storage/v3/transaction.hpp" #include "storage/v3/vertex.hpp" #include "utils/skip_list.hpp" namespace memgraph::benchmark { /////////////////////////////////////////////////////////////////////////////// // Testing Insert Operation /////////////////////////////////////////////////////////////////////////////// static void BM_BenchmarkInsertSkipList(::benchmark::State &state) { utils::SkipList skip_list; coordinator::Hlc start_timestamp; storage::v3::Transaction transaction{start_timestamp, storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { auto acc = skip_list.access(); acc.insert({storage::v3::PrimaryKey{storage::v3::PropertyValue{true}}}); } } } static void BM_BenchmarkInsertStdMap(::benchmark::State &state) { std::map std_map; coordinator::Hlc start_timestamp; storage::v3::Transaction transaction{start_timestamp, storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; auto *delta = storage::v3::CreateDeleteObjectDelta(&transaction); for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { std_map.insert({storage::v3::PrimaryKey{storage::v3::PropertyValue{i}}, storage::v3::VertexData{delta}}); } } } static void BM_BenchmarkInsertStdSet(::benchmark::State &state) { std::set std_set; for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { std_set.insert( storage::v3::PrimaryKey{std::vector{storage::v3::PropertyValue{true}}}); } } } BENCHMARK(BM_BenchmarkInsertSkipList)->RangeMultiplier(10)->Range(1000, 10000000)->Unit(::benchmark::kMillisecond); BENCHMARK(BM_BenchmarkInsertStdMap)->RangeMultiplier(10)->Range(1000, 10000000)->Unit(::benchmark::kMillisecond); BENCHMARK(BM_BenchmarkInsertStdSet)->RangeMultiplier(10)->Range(1000, 10000000)->Unit(::benchmark::kMillisecond); } // namespace memgraph::benchmark BENCHMARK_MAIN();