From 0960337a86fd6f1b24d26ef95be95842d2bd222c Mon Sep 17 00:00:00 2001 From: codeworse Date: Sun, 8 Jun 2025 22:59:47 +0000 Subject: [PATCH 1/5] modify workflow --- .github/workflows/c-cpp.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 735024e..2756395 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -14,12 +14,15 @@ jobs: steps: - uses: actions/checkout@v4 - name: build + uses: actions/upload-artifact@v4 run: mkdir build && cd build && cmake .. && make -j `nproc` - name: build_asan + uses: actions/upload-artifact@v4 run: mkdir build_asan && cd build_asan && cmake -DENABLE_ASAN=ON .. && make -j `nproc` - name: build_tsan run: mkdir build_tsan && cd build_tsan && cmake -DENABLE_TSAN=ON .. && make -j `nproc` - name: build_ubsan + uses: actions/upload-artifact@v4 run: mkdir build_ubsan && cd build_ubsan && cmake -DENABLE_UBSAN=ON .. && make -j `nproc` - name: Upload builds uses: actions/upload-artifact@v4 From b48fc37adb88a2dea670206e73ccae86c2ae9f30 Mon Sep 17 00:00:00 2001 From: codeworse Date: Sun, 8 Jun 2025 23:01:06 +0000 Subject: [PATCH 2/5] modify workflow modify workflow modify workflow modify workflow modify workflow modify workflow fix fix fix fix --- .github/workflows/c-cpp.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 2756395..735024e 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -14,15 +14,12 @@ jobs: steps: - uses: actions/checkout@v4 - name: build - uses: actions/upload-artifact@v4 run: mkdir build && cd build && cmake .. && make -j `nproc` - name: build_asan - uses: actions/upload-artifact@v4 run: mkdir build_asan && cd build_asan && cmake -DENABLE_ASAN=ON .. && make -j `nproc` - name: build_tsan run: mkdir build_tsan && cd build_tsan && cmake -DENABLE_TSAN=ON .. && make -j `nproc` - name: build_ubsan - uses: actions/upload-artifact@v4 run: mkdir build_ubsan && cd build_ubsan && cmake -DENABLE_UBSAN=ON .. && make -j `nproc` - name: Upload builds uses: actions/upload-artifact@v4 From a3a6177261e12bf77f3af5178b017e1aff76591c Mon Sep 17 00:00:00 2001 From: codeworse Date: Mon, 9 Jun 2025 21:31:48 +0000 Subject: [PATCH 3/5] add clang-format --- .clang-format | 2 +- .github/workflows/c-cpp.yml | 8 ++ src/metrics/counter_basic.cpp | 5 +- src/metrics/counter_basic.h | 126 ++++++++++++++-------------- src/metrics/counter_minmax.h | 99 +++++++++++----------- src/metrics/counter_sum.h | 54 ++++++------ tests/metrics.cpp | 151 +++++++++++++++++----------------- 7 files changed, 226 insertions(+), 219 deletions(-) diff --git a/.clang-format b/.clang-format index dc69733..274fb98 100644 --- a/.clang-format +++ b/.clang-format @@ -78,6 +78,6 @@ SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: c++11 +Standard: c++20 TabWidth: 4 UseTab: Never \ No newline at end of file diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 735024e..9b6ae6e 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -45,3 +45,11 @@ jobs: cd builds/build_ubsan chmod +x tests/tests tests/tests + format: + runs-on: ubuntu-latest + steps: + - name: Install clang-format + run: sudo apt install -y clang-format + - uses: actions/checkout@v4 + - name: Check clang-format + run: find ./ -iname '*.h' -o -iname '*.cpp' | xargs clang-format -n --Werror diff --git a/src/metrics/counter_basic.cpp b/src/metrics/counter_basic.cpp index 16715a4..48ed28f 100644 --- a/src/metrics/counter_basic.cpp +++ b/src/metrics/counter_basic.cpp @@ -3,6 +3,5 @@ #include namespace ciri { -namespace metrics { -} -} \ No newline at end of file +namespace metrics {} +} // namespace ciri \ No newline at end of file diff --git a/src/metrics/counter_basic.h b/src/metrics/counter_basic.h index fda1fd1..1417ae6 100644 --- a/src/metrics/counter_basic.h +++ b/src/metrics/counter_basic.h @@ -1,82 +1,84 @@ #pragma once +#include #include +#include #include -#include -#include #include -#include -#include #include +#include +#include namespace ciri { namespace metrics { -template +template class CounterBasic { -public: - static const size_t alignment = 64; - CounterBasic(size_t capacity) : - fast_module((capacity & (capacity - 1)) == 0) - , capacity_(capacity) { - assert(capacity_ > 0); - counters_ = static_cast*>(std::aligned_alloc(alignment, capacity * sizeof(decltype(counters_[0])))); - assert(counters_ != nullptr); - for (size_t i = 0; i < capacity_; ++i) { - new (counters_ + i) std::atomic(); - } - for (size_t i = 0; i < capacity_; ++i) { - counters_[i].store(0); - } + public: + static const size_t alignment = 64; + CounterBasic(size_t capacity) + : fast_module((capacity & (capacity - 1)) == 0), capacity_(capacity) { + assert(capacity_ > 0); + counters_ = static_cast*>(std::aligned_alloc( + alignment, capacity * sizeof(decltype(counters_[0])))); + assert(counters_ != nullptr); + for (size_t i = 0; i < capacity_; ++i) { + new (counters_ + i) std::atomic(); } - void increase(T inc) { - size_t thread_hash = std::hash{}(std::this_thread::get_id()); - counters_[get_index(thread_hash)].fetch_add(inc, std::memory_order_relaxed); - } - void decrease(T dec) { - size_t thread_hash = std::hash{}(std::this_thread::get_id()); - counters_[get_index(thread_hash)].fetch_sub(dec, std::memory_order_relaxed); - } - void set(T value) { - size_t thread_hash = std::hash{}(std::this_thread::get_id()); - counters_[get_index(thread_hash)].store(value, std::memory_order_relaxed); + for (size_t i = 0; i < capacity_; ++i) { + counters_[i].store(0); } + } + void increase(T inc) { + size_t thread_hash = + std::hash{}(std::this_thread::get_id()); + counters_[get_index(thread_hash)].fetch_add(inc, std::memory_order_relaxed); + } + void decrease(T dec) { + size_t thread_hash = + std::hash{}(std::this_thread::get_id()); + counters_[get_index(thread_hash)].fetch_sub(dec, std::memory_order_relaxed); + } + void set(T value) { + size_t thread_hash = + std::hash{}(std::this_thread::get_id()); + counters_[get_index(thread_hash)].store(value, std::memory_order_relaxed); + } - template&> F> - void call(F&& callback) { - size_t thread_hash = std::hash{}(std::this_thread::get_id()); - callback(counters_[get_index(thread_hash)]); - } + template &> F> + void call(F&& callback) { + size_t thread_hash = + std::hash{}(std::this_thread::get_id()); + callback(counters_[get_index(thread_hash)]); + } - inline void get_index() const { - size_t thread_hash = std::hash{}(std::this_thread::get_id()); - return get_index(thread_hash); - } + inline void get_index() const { + size_t thread_hash = + std::hash{}(std::this_thread::get_id()); + return get_index(thread_hash); + } - - template&> F> - void iterate(F&& func) { - for (size_t i = 0; i < capacity_; ++i) { - func(counters_[i]); - } + template &> F> + void iterate(F&& func) { + for (size_t i = 0; i < capacity_; ++i) { + func(counters_[i]); } + } - template&> F> - void iterate(F&& func) const { - for (size_t i = 0; i < capacity_; ++i) { - func(counters_[i]); - } - } - - ~CounterBasic() { - std::free(counters_); + template &> F> + void iterate(F&& func) const { + for (size_t i = 0; i < capacity_; ++i) { + func(counters_[i]); } + } - inline size_t get_index(size_t i) const { - return fast_module ? (i & (capacity_ - 1)) : (i % capacity_); - } - const bool fast_module = false; - const size_t capacity_{0}; - alignas(alignment) std::atomic* counters_{nullptr}; + ~CounterBasic() { std::free(counters_); } + + inline size_t get_index(size_t i) const { + return fast_module ? (i & (capacity_ - 1)) : (i % capacity_); + } + const bool fast_module = false; + const size_t capacity_{0}; + alignas(alignment) std::atomic* counters_{nullptr}; }; -} -} \ No newline at end of file +} // namespace metrics +} // namespace ciri \ No newline at end of file diff --git a/src/metrics/counter_minmax.h b/src/metrics/counter_minmax.h index 6eafc72..83fda31 100644 --- a/src/metrics/counter_minmax.h +++ b/src/metrics/counter_minmax.h @@ -5,60 +5,59 @@ namespace ciri { namespace metrics { -template +template class CounterMinMax { -public: - enum Mode { - Min, - Max - }; - struct CompareCallback { - Mode mode; - T upd; - void operator()(std::atomic& element) { - while (true) { - T value = element.load(std::memory_order_relaxed); - if ((value <= upd && mode == Mode::Min) || (value >= upd && mode == Mode::Max)) { - break; - } - if (element.compare_exchange_strong(value, upd, std::memory_order_relaxed)) { - break; - } - } + public: + enum Mode { Min, Max }; + struct CompareCallback { + Mode mode; + T upd; + void operator()(std::atomic& element) { + while (true) { + T value = element.load(std::memory_order_relaxed); + if ((value <= upd && mode == Mode::Min) || + (value >= upd && mode == Mode::Max)) { + break; } - }; - CounterMinMax(Mode mode, size_t capacity = 1) : mode_(mode), counter_(capacity) { - + if (element.compare_exchange_strong(value, upd, + std::memory_order_relaxed)) { + break; + } + } } + }; + CounterMinMax(Mode mode, size_t capacity = 1) + : mode_(mode), counter_(capacity) {} - void update(T upd) { - CompareCallback callback{.mode = mode_, .upd = std::move(upd)}; - counter_.call(callback); - } + void update(T upd) { + CompareCallback callback{.mode = mode_, .upd = std::move(upd)}; + counter_.call(callback); + } - T get() const { - T result = T{}; - auto max_func = [&](const std::atomic& element) { - T value = element.load(std::memory_order_relaxed); - result = result > value ? result : value; - }; - auto min_func = [&](const std::atomic& element) { - T value = element.load(std::memory_order_relaxed); - result = result < value ? result : value; - }; - switch (mode_) { - case Mode::Max: - counter_.iterate(max_func); - return result; - case Mode::Min: - counter_.iterate(min_func); - return result; - } - assert(false); + T get() const { + T result = T{}; + auto max_func = [&](const std::atomic& element) { + T value = element.load(std::memory_order_relaxed); + result = result > value ? result : value; + }; + auto min_func = [&](const std::atomic& element) { + T value = element.load(std::memory_order_relaxed); + result = result < value ? result : value; + }; + switch (mode_) { + case Mode::Max: + counter_.iterate(max_func); + return result; + case Mode::Min: + counter_.iterate(min_func); + return result; } -private: - Mode mode_; - CounterBasic counter_; + assert(false); + } + + private: + Mode mode_; + CounterBasic counter_; }; -} -} \ No newline at end of file +} // namespace metrics +} // namespace ciri \ No newline at end of file diff --git a/src/metrics/counter_sum.h b/src/metrics/counter_sum.h index 12e0caf..8a871f9 100644 --- a/src/metrics/counter_sum.h +++ b/src/metrics/counter_sum.h @@ -1,42 +1,38 @@ #pragma once +#include #include +#include #include -#include -#include #include -#include -#include #include +#include +#include #include "metrics/counter_basic.h" namespace ciri { namespace metrics { -template +template class CounterSum { -public: - static const size_t alignment = 64; - CounterSum(size_t capacity = 1) : counter_(capacity) { - } - void increase(T inc) { - counter_.increase(inc); - } - void decrease(T dec) { - counter_.decrease(dec); - } - T get() const { - T sum = T{}; - auto f = [&](const std::atomic& element) { - sum += element.load(std::memory_order_relaxed); - }; - counter_.iterate(f); - return sum; - } + public: + static const size_t alignment = 64; + CounterSum(size_t capacity = 1) : counter_(capacity) {} + void increase(T inc) { counter_.increase(inc); } + void decrease(T dec) { counter_.decrease(dec); } + T get() const { + T sum = T{}; + auto f = [&](const std::atomic& element) { + sum += element.load(std::memory_order_relaxed); + }; + counter_.iterate(f); + return sum; + } + + ~CounterSum() = default; - ~CounterSum() = default; -private: - const bool fast_module = false; - ciri::metrics::CounterBasic counter_; + private: + const bool fast_module = false; + ciri::metrics::CounterBasic counter_; }; -} -} \ No newline at end of file +} // namespace metrics +} // namespace ciri \ No newline at end of file diff --git a/tests/metrics.cpp b/tests/metrics.cpp index 91fbe58..d696f85 100644 --- a/tests/metrics.cpp +++ b/tests/metrics.cpp @@ -1,95 +1,98 @@ -#include +#include #include -#include "metrics/counter_sum.h" -#include "metrics/counter_minmax.h" +#include #include "metrics/counter_basic.h" -#include - +#include "metrics/counter_minmax.h" +#include "metrics/counter_sum.h" using namespace std::chrono_literals; - TEST(MetricsTests, CounterSum) { - ciri::metrics::CounterSum c; - for (size_t i = 0; i < 100; ++i) { - c.increase(10); - } + ciri::metrics::CounterSum c; + for (size_t i = 0; i < 100; ++i) { + c.increase(10); + } - for (size_t i = 0; i < 100; ++i) { - c.decrease(10); - } + for (size_t i = 0; i < 100; ++i) { + c.decrease(10); + } - std::atomic_thread_fence(std::memory_order_acquire); - EXPECT_EQ(c.get(), 0); + std::atomic_thread_fence(std::memory_order_acquire); + EXPECT_EQ(c.get(), 0); } TEST(MetricsTests, CounterMax) { - size_t n = 4; - size_t iterations = 100'000'000; + size_t n = 4; + size_t iterations = 100 '000' 000; + std::vector threads; + threads.reserve(n); + ciri::metrics::CounterMinMax c( + ciri::metrics::CounterMinMax::Mode::Max, 4); + for (size_t i = 0; i < n; ++i) { + threads.emplace_back([&c, &iterations, num = i]() { + for (size_t i = 0; i <= iterations; ++i) { + c.update(num * i); + } + }); + } + for (size_t i = 0; i < n; ++i) { + threads[i].join(); + } + std::atomic_thread_fence(std::memory_order_acquire); + + EXPECT_EQ(c.get(), (n - 1) * iterations); +} + +TEST(MetricsTests, CounterStress) { + size_t n = 4; + size_t iterations = 100 '000' 000; + { std::vector threads; threads.reserve(n); - ciri::metrics::CounterMinMax c(ciri::metrics::CounterMinMax::Mode::Max, 4); + std::atomic_size_t dummy; + std::cout << "dummy: "; + auto start = std::chrono::system_clock::now(); for (size_t i = 0; i < n; ++i) { - threads.emplace_back([&c, &iterations, num = i]() { - for (size_t i = 0; i <= iterations; ++i) { - c.update(num * i); - } - }); + threads.emplace_back([&]() { + size_t sum = 0; + for (size_t k = 0; k < iterations; ++k) { + dummy.fetch_add(k, std::memory_order_relaxed); + } + }); } + size_t sum = dummy.load(std::memory_order_relaxed); for (size_t i = 0; i < n; ++i) { - threads[i].join(); + threads[i].join(); } - std::atomic_thread_fence(std::memory_order_acquire); - - EXPECT_EQ(c.get(), (n - 1) * iterations); -} - -TEST(MetricsTests, CounterStress) { - size_t n = 4; - size_t iterations = 100'000'000; - { - std::vector threads; - threads.reserve(n); - std::atomic_size_t dummy; - std::cout << "dummy: "; - auto start = std::chrono::system_clock::now(); - for (size_t i = 0; i < n; ++i) { - threads.emplace_back([&]() { - size_t sum = 0; - for (size_t k = 0; k < iterations; ++k) { - dummy.fetch_add(k, std::memory_order_relaxed); - } - }); - } - size_t sum = dummy.load(std::memory_order_relaxed); - for (size_t i = 0; i < n; ++i) { - threads[i].join(); + threads.clear(); + auto finish = std::chrono::system_clock::now(); + auto duration = finish - start; + std::cout << std::chrono::duration_cast(duration) + .count() + << "ms\n"; + } + { + std::vector threads; + threads.reserve(n); + ciri::metrics::CounterSum c(1); + std::cout << "ciri: "; + auto start = std::chrono::system_clock::now(); + for (size_t i = 0; i < n; ++i) { + threads.emplace_back([&]() { + size_t sum = 0; + for (size_t k = 0; k < iterations; ++k) { + c.increase(k); } - threads.clear(); - auto finish = std::chrono::system_clock::now(); - auto duration = finish - start; - std::cout << std::chrono::duration_cast(duration).count() << "ms\n"; + }); } - { - std::vector threads; - threads.reserve(n); - ciri::metrics::CounterSum c(1); - std::cout << "ciri: "; - auto start = std::chrono::system_clock::now(); - for (size_t i = 0; i < n; ++i) { - threads.emplace_back([&]() { - size_t sum = 0; - for (size_t k = 0; k < iterations; ++k) { - c.increase(k); - } - }); - } - size_t sum = c.get(); - for (size_t i = 0; i < n; ++i) { - threads[i].join(); - } - auto finish = std::chrono::system_clock::now(); - auto duration = finish - start; - std::cout << std::chrono::duration_cast(duration).count() << "ms\n"; + size_t sum = c.get(); + for (size_t i = 0; i < n; ++i) { + threads[i].join(); } + auto finish = std::chrono::system_clock::now(); + auto duration = finish - start; + std::cout << std::chrono::duration_cast(duration) + .count() + << "ms\n"; + } } From 4be5fb57767103135be82c928c36e4f48ba70f4e Mon Sep 17 00:00:00 2001 From: codeworse Date: Mon, 9 Jun 2025 21:36:23 +0000 Subject: [PATCH 4/5] add empty line --- .clang-format | 2 +- .gitignore | 2 +- CMakeLists.txt | 2 +- src/metrics/counter_basic.cpp | 2 +- src/metrics/counter_basic.h | 2 +- src/metrics/counter_minmax.h | 2 +- src/metrics/counter_sum.h | 2 +- tests/CMakeLists.txt | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.clang-format b/.clang-format index 274fb98..734a436 100644 --- a/.clang-format +++ b/.clang-format @@ -80,4 +80,4 @@ SpacesInParentheses: false SpacesInSquareBrackets: false Standard: c++20 TabWidth: 4 -UseTab: Never \ No newline at end of file +UseTab: Never diff --git a/.gitignore b/.gitignore index ee6d40f..7170c9a 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,4 @@ *.out *.app -build/ \ No newline at end of file +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e7ec613..47d7212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,4 +51,4 @@ FetchContent_Declare( FetchContent_MakeAvailable(googletest) target_include_directories(ciri PUBLIC src) -add_subdirectory(tests) \ No newline at end of file +add_subdirectory(tests) diff --git a/src/metrics/counter_basic.cpp b/src/metrics/counter_basic.cpp index 48ed28f..936525b 100644 --- a/src/metrics/counter_basic.cpp +++ b/src/metrics/counter_basic.cpp @@ -4,4 +4,4 @@ namespace ciri { namespace metrics {} -} // namespace ciri \ No newline at end of file +} // namespace ciri diff --git a/src/metrics/counter_basic.h b/src/metrics/counter_basic.h index 1417ae6..8db679e 100644 --- a/src/metrics/counter_basic.h +++ b/src/metrics/counter_basic.h @@ -81,4 +81,4 @@ class CounterBasic { alignas(alignment) std::atomic* counters_{nullptr}; }; } // namespace metrics -} // namespace ciri \ No newline at end of file +} // namespace ciri diff --git a/src/metrics/counter_minmax.h b/src/metrics/counter_minmax.h index 83fda31..daf18b7 100644 --- a/src/metrics/counter_minmax.h +++ b/src/metrics/counter_minmax.h @@ -60,4 +60,4 @@ class CounterMinMax { CounterBasic counter_; }; } // namespace metrics -} // namespace ciri \ No newline at end of file +} // namespace ciri diff --git a/src/metrics/counter_sum.h b/src/metrics/counter_sum.h index 8a871f9..9358724 100644 --- a/src/metrics/counter_sum.h +++ b/src/metrics/counter_sum.h @@ -35,4 +35,4 @@ class CounterSum { }; } // namespace metrics -} // namespace ciri \ No newline at end of file +} // namespace ciri diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 864619c..b21e9d3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,4 +14,4 @@ if(ENABLE_ASAN) endif() include(GoogleTest) -gtest_discover_tests(tests) \ No newline at end of file +gtest_discover_tests(tests) From d006c1147380bf1bb55fbebc22f99432e86cc489 Mon Sep 17 00:00:00 2001 From: codeworse Date: Mon, 9 Jun 2025 21:57:32 +0000 Subject: [PATCH 5/5] fixes --- CMakeLists.txt | 2 +- src/metrics/counter_basic.cpp | 1 + src/metrics/counter_minmax.h | 1 + src/metrics/counter_sum.h | 1 + tests/metrics.cpp | 16 ++++++---------- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47d7212..7f322ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer" OFF) message("ASAN: " ${ENABLE_ASAN}) message("MSAN: " ${ENABLE_MSAN}) -message("TSAB: " ${ENABLE_TSAN}) +message("TSAN: " ${ENABLE_TSAN}) message("UBSAN: " ${ENABLE_UBSAN}) if(ENABLE_ASAN) message(STATUS "Enabling AddressSanitizer") diff --git a/src/metrics/counter_basic.cpp b/src/metrics/counter_basic.cpp index 936525b..0427076 100644 --- a/src/metrics/counter_basic.cpp +++ b/src/metrics/counter_basic.cpp @@ -1,4 +1,5 @@ #include "metrics/counter_basic.h" + #include #include diff --git a/src/metrics/counter_minmax.h b/src/metrics/counter_minmax.h index daf18b7..f869a22 100644 --- a/src/metrics/counter_minmax.h +++ b/src/metrics/counter_minmax.h @@ -1,6 +1,7 @@ #pragma once #include #include + #include "metrics/counter_basic.h" namespace ciri { namespace metrics { diff --git a/src/metrics/counter_sum.h b/src/metrics/counter_sum.h index 9358724..58ecbf1 100644 --- a/src/metrics/counter_sum.h +++ b/src/metrics/counter_sum.h @@ -7,6 +7,7 @@ #include #include #include + #include "metrics/counter_basic.h" namespace ciri { diff --git a/tests/metrics.cpp b/tests/metrics.cpp index d696f85..c3e7cc1 100644 --- a/tests/metrics.cpp +++ b/tests/metrics.cpp @@ -1,6 +1,7 @@ #include #include #include + #include "metrics/counter_basic.h" #include "metrics/counter_minmax.h" #include "metrics/counter_sum.h" @@ -23,11 +24,10 @@ TEST(MetricsTests, CounterSum) { TEST(MetricsTests, CounterMax) { size_t n = 4; - size_t iterations = 100 '000' 000; + size_t iterations = 100'000'000; // clang-format off std::vector threads; threads.reserve(n); - ciri::metrics::CounterMinMax c( - ciri::metrics::CounterMinMax::Mode::Max, 4); + ciri::metrics::CounterMinMax c(ciri::metrics::CounterMinMax::Mode::Max, 4); for (size_t i = 0; i < n; ++i) { threads.emplace_back([&c, &iterations, num = i]() { for (size_t i = 0; i <= iterations; ++i) { @@ -45,7 +45,7 @@ TEST(MetricsTests, CounterMax) { TEST(MetricsTests, CounterStress) { size_t n = 4; - size_t iterations = 100 '000' 000; + size_t iterations = 100'000'000; // clang-format off { std::vector threads; threads.reserve(n); @@ -67,9 +67,7 @@ TEST(MetricsTests, CounterStress) { threads.clear(); auto finish = std::chrono::system_clock::now(); auto duration = finish - start; - std::cout << std::chrono::duration_cast(duration) - .count() - << "ms\n"; + std::cout << std::chrono::duration_cast(duration).count() << "ms\n"; } { std::vector threads; @@ -91,8 +89,6 @@ TEST(MetricsTests, CounterStress) { } auto finish = std::chrono::system_clock::now(); auto duration = finish - start; - std::cout << std::chrono::duration_cast(duration) - .count() - << "ms\n"; + std::cout << std::chrono::duration_cast(duration).count() << "ms\n"; } }