From 8d0b7060ec4b09033794b71532d7608bc217a549 Mon Sep 17 00:00:00 2001 From: TurinTech Bot Date: Fri, 1 Mar 2024 15:10:28 +0000 Subject: [PATCH] Artemis Changes --- f1.cpp | 7 ++++--- high_load.cpp | 13 ++++++++++--- post_test.sh | 0 3 files changed, 14 insertions(+), 6 deletions(-) mode change 100755 => 100644 post_test.sh diff --git a/f1.cpp b/f1.cpp index 97ea106..23b7a71 100644 --- a/f1.cpp +++ b/f1.cpp @@ -29,18 +29,19 @@ bool F1::run() } vector> edges; + edges.reserve(N - 1 + (total - K)); // Reserve space to avoid reallocations for (int i = 2; i <= N; ++i) { - edges.push_back({1, i}); + edges.emplace_back(1, i); } for (int i = 2; i < N && total > K; ++i) { for (int j = i + 1; j <= N && total > K; ++j, --total) { - edges.push_back({i, j}); + edges.emplace_back(i, j); } } return true; -} +} \ No newline at end of file diff --git a/high_load.cpp b/high_load.cpp index 836fe26..d778aca 100644 --- a/high_load.cpp +++ b/high_load.cpp @@ -1,3 +1,8 @@ +#include +#include +#include +#include +#include #include "high_load.h" #include @@ -18,8 +23,10 @@ bool BenchmarkRunner::benchmark(){ // Insert random keys for (int i = 0; i < 1000; i++) { int random_key = rand() % 100000; - test_map[random_key] = 0; - test_keys.push_back(random_key); + auto result = test_map.insert(std::make_pair(random_key, 0)); + if (result.second) { + test_keys.push_back(random_key); + } } for (int key : test_keys) { @@ -28,4 +35,4 @@ bool BenchmarkRunner::benchmark(){ map m; } return true; -} +} \ No newline at end of file diff --git a/post_test.sh b/post_test.sh old mode 100755 new mode 100644