From 884831ece5849a1ba46fa0132e581f0f7f5f3693 Mon Sep 17 00:00:00 2001 From: jbajic Date: Tue, 29 Nov 2022 11:56:01 +0100 Subject: [PATCH] Use pk --- tests/benchmark/data_structures_common.hpp | 6 +++--- tests/benchmark/data_structures_contains.cpp | 7 +++---- tests/benchmark/data_structures_find.cpp | 7 +++---- tests/benchmark/data_structures_insert.cpp | 9 ++++----- tests/benchmark/data_structures_remove.cpp | 10 ++++------ 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/tests/benchmark/data_structures_common.hpp b/tests/benchmark/data_structures_common.hpp index fe6129a22..fb9053c67 100644 --- a/tests/benchmark/data_structures_common.hpp +++ b/tests/benchmark/data_structures_common.hpp @@ -17,6 +17,7 @@ #include "btree_map.hpp" #include "coordinator/hybrid_logical_clock.hpp" +#include "storage/v3/key_store.hpp" #include "storage/v3/lexicographically_ordered_vertex.hpp" #include "storage/v3/mvcc.hpp" #include "storage/v3/transaction.hpp" @@ -32,7 +33,7 @@ inline void PrepareData(utils::SkipList &skip_list, const int64_t num_element auto *delta = storage::v3::CreateDeleteObjectDelta(&transaction); for (auto i{0}; i < num_elements; ++i) { auto acc = skip_list.access(); - acc.insert({storage::v3::Vertex(delta, std::vector{storage::v3::PropertyValue{i}})}); + acc.insert({storage::v3::PrimaryKey{storage::v3::PropertyValue{i}}}); } } @@ -56,8 +57,7 @@ inline void PrepareData(std::set &std_set, const int64_t num_elements) { storage::v3::Transaction transaction{start_timestamp, isolation_level}; auto *delta = storage::v3::CreateDeleteObjectDelta(&transaction); for (auto i{0}; i < num_elements; ++i) { - std_set.insert(storage::v3::LexicographicallyOrderedVertex{ - storage::v3::Vertex{delta, std::vector{storage::v3::PropertyValue{i}}}}); + std_set.insert(std::vector{storage::v3::PropertyValue{i}}); } } diff --git a/tests/benchmark/data_structures_contains.cpp b/tests/benchmark/data_structures_contains.cpp index 604ab6ef9..2950aeed3 100644 --- a/tests/benchmark/data_structures_contains.cpp +++ b/tests/benchmark/data_structures_contains.cpp @@ -39,7 +39,7 @@ namespace memgraph::benchmark { // Testing Contains Operation /////////////////////////////////////////////////////////////////////////////// static void BM_BenchmarkContainsSkipList(::benchmark::State &state) { - utils::SkipList skip_list; + utils::SkipList skip_list; PrepareData(skip_list, state.range(0)); // So we can also have elements that does don't exist std::mt19937 i_generator(std::random_device{}()); @@ -77,7 +77,7 @@ static void BM_BenchmarkContainsStdMap(::benchmark::State &state) { } static void BM_BenchmarkContainsStdSet(::benchmark::State &state) { - std::set std_set; + std::set std_set; PrepareData(std_set, state.range(0)); coordinator::Hlc start_timestamp; storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; @@ -90,8 +90,7 @@ static void BM_BenchmarkContainsStdSet(::benchmark::State &state) { for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { int64_t value = i_distribution(i_generator); - if (std_set.contains(storage::v3::LexicographicallyOrderedVertex{ - storage::v3::Vertex{delta, storage::v3::PrimaryKey{storage::v3::PropertyValue{value}}}})) { + if (std_set.contains(storage::v3::PrimaryKey{storage::v3::PropertyValue{value}})) { found_elems++; } } diff --git a/tests/benchmark/data_structures_find.cpp b/tests/benchmark/data_structures_find.cpp index 502be91da..f1f1955c4 100644 --- a/tests/benchmark/data_structures_find.cpp +++ b/tests/benchmark/data_structures_find.cpp @@ -39,7 +39,7 @@ namespace memgraph::benchmark { // Testing Find Operation /////////////////////////////////////////////////////////////////////////////// static void BM_BenchmarkFindSkipList(::benchmark::State &state) { - utils::SkipList skip_list; + utils::SkipList skip_list; PrepareData(skip_list, state.range(0)); // So we can also have elements that does don't exist std::mt19937 i_generator(std::random_device{}()); @@ -76,7 +76,7 @@ static void BM_BenchmarkFindStdMap(::benchmark::State &state) { } static void BM_BenchmarkFindStdSet(::benchmark::State &state) { - std::set std_set; + std::set std_set; PrepareData(std_set, state.range(0)); coordinator::Hlc start_timestamp; storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; @@ -90,8 +90,7 @@ static void BM_BenchmarkFindStdSet(::benchmark::State &state) { for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { int64_t value = i_distribution(i_generator); - if (std_set.find(storage::v3::LexicographicallyOrderedVertex{storage::v3::Vertex{ - delta, storage::v3::PrimaryKey{storage::v3::PropertyValue{value}}}}) != std_set.end()) { + if (std_set.find(storage::v3::PrimaryKey{storage::v3::PropertyValue{value}}) != std_set.end()) { found_elems++; } } diff --git a/tests/benchmark/data_structures_insert.cpp b/tests/benchmark/data_structures_insert.cpp index 024c23202..1e5361d62 100644 --- a/tests/benchmark/data_structures_insert.cpp +++ b/tests/benchmark/data_structures_insert.cpp @@ -38,7 +38,7 @@ namespace memgraph::benchmark { // Testing Insert Operation /////////////////////////////////////////////////////////////////////////////// static void BM_BenchmarkInsertSkipList(::benchmark::State &state) { - utils::SkipList skip_list; + utils::SkipList skip_list; coordinator::Hlc start_timestamp; storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; storage::v3::Transaction transaction{start_timestamp, isolation_level}; @@ -47,7 +47,7 @@ static void BM_BenchmarkInsertSkipList(::benchmark::State &state) { for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { auto acc = skip_list.access(); - acc.insert({storage::v3::Vertex(delta, std::vector{storage::v3::PropertyValue{i}})}); + acc.insert({storage::v3::PrimaryKey{storage::v3::PropertyValue{i}}}); } } } @@ -69,7 +69,7 @@ static void BM_BenchmarkInsertStdMap(::benchmark::State &state) { } static void BM_BenchmarkInsertStdSet(::benchmark::State &state) { - std::set std_set; + std::set std_set; coordinator::Hlc start_timestamp; storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; storage::v3::Transaction transaction{start_timestamp, isolation_level}; @@ -77,8 +77,7 @@ static void BM_BenchmarkInsertStdSet(::benchmark::State &state) { for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { - std_set.insert(storage::v3::LexicographicallyOrderedVertex{ - storage::v3::Vertex{delta, std::vector{storage::v3::PropertyValue{i}}}}); + std_set.insert(storage::v3::PrimaryKey{std::vector{storage::v3::PropertyValue{i}}}); } } } diff --git a/tests/benchmark/data_structures_remove.cpp b/tests/benchmark/data_structures_remove.cpp index aa02820fc..17dbd1dec 100644 --- a/tests/benchmark/data_structures_remove.cpp +++ b/tests/benchmark/data_structures_remove.cpp @@ -39,7 +39,7 @@ namespace memgraph::benchmark { // Testing Remove Operation /////////////////////////////////////////////////////////////////////////////// static void BM_BenchmarkRemoveSkipList(::benchmark::State &state) { - utils::SkipList skip_list; + utils::SkipList skip_list; PrepareData(skip_list, state.range(0)); coordinator::Hlc start_timestamp; storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; @@ -54,8 +54,7 @@ static void BM_BenchmarkRemoveSkipList(::benchmark::State &state) { for (auto i{0}; i < state.range(0); ++i) { int64_t value = i_distribution(i_generator); auto acc = skip_list.access(); - if (acc.remove(storage::v3::LexicographicallyOrderedVertex{ - storage::v3::Vertex{delta, storage::v3::PrimaryKey{storage::v3::PropertyValue(value)}}})) { + if (acc.remove(storage::v3::PrimaryKey{storage::v3::PropertyValue(value)})) { removed_elems++; } } @@ -83,7 +82,7 @@ static void BM_BenchmarkRemoveStdMap(::benchmark::State &state) { } static void BM_BenchmarkRemoveStdSet(::benchmark::State &state) { - std::set std_set; + std::set std_set; PrepareData(std_set, state.range(0)); coordinator::Hlc start_timestamp; storage::v3::IsolationLevel isolation_level{storage::v3::IsolationLevel::SNAPSHOT_ISOLATION}; @@ -97,8 +96,7 @@ static void BM_BenchmarkRemoveStdSet(::benchmark::State &state) { for (auto _ : state) { for (auto i{0}; i < state.range(0); ++i) { int64_t value = i_distribution(i_generator); - if (std_set.erase(storage::v3::LexicographicallyOrderedVertex{ - storage::v3::Vertex{delta, {storage::v3::PropertyValue{value}}}}) > 0) { + if (std_set.erase(storage::v3::PrimaryKey{storage::v3::PropertyValue{value}}) > 0) { removed_elems++; } }