From b6cb5d25b951a5ffdaf7508e9832e05de02f5479 Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Fri, 11 Oct 2024 16:30:02 +0800 Subject: [PATCH 1/3] enable coverage for more test --- coverage_gen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coverage_gen.sh b/coverage_gen.sh index d6e976f95..f0821e7db 100644 --- a/coverage_gen.sh +++ b/coverage_gen.sh @@ -35,8 +35,8 @@ make -j export LLVM_PROFILE_FILE="ylt_test-%m.profraw" ls cd output -./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize +./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize ./tests/metric_test ./tests/struct_pb_test ./tests/reflection_test llvm-profdata merge -sparse ylt_test-*.profraw -o ylt_test.profdata -llvm-cov show ./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false +llvm-cov show ./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize ./tests/metric_test ./tests/struct_pb_test ./tests/reflection_test -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false echo 'Done!!!' fi From 6e6f01ec6f1aec09d5907cc455ba75c42da024ee Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Fri, 11 Oct 2024 16:30:18 +0800 Subject: [PATCH 2/3] [metric] set default check duration to 60s --- include/ylt/metric/metric.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/ylt/metric/metric.hpp b/include/ylt/metric/metric.hpp index 7ce70203c..50a03e3cd 100644 --- a/include/ylt/metric/metric.hpp +++ b/include/ylt/metric/metric.hpp @@ -195,7 +195,7 @@ class static_metric : public metric_t { }; inline std::chrono::seconds ylt_label_max_age{0}; -inline std::chrono::seconds ylt_label_check_expire_duration{0}; +inline std::chrono::seconds ylt_label_check_expire_duration{60}; inline std::atomic ylt_metric_capacity = 10000000; inline int64_t ylt_label_capacity = 20000000; @@ -210,7 +210,7 @@ inline void set_label_capacity(int64_t max_label_count) { inline void set_label_max_age( std::chrono::seconds max_age, - std::chrono::seconds check_duration = std::chrono::seconds(60 * 10)) { + std::chrono::seconds check_duration = std::chrono::seconds{60}) { ylt_label_max_age = max_age; ylt_label_check_expire_duration = check_duration; } From bf5d6dfab05803fad9a3795edf41efacc6e61c04 Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Fri, 11 Oct 2024 16:54:37 +0800 Subject: [PATCH 3/3] [metric] fix test out-of-memory on msvc x86 --- src/metric/benchmark/bench.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/metric/benchmark/bench.hpp b/src/metric/benchmark/bench.hpp index 250bf0e6b..ce9e42777 100644 --- a/src/metric/benchmark/bench.hpp +++ b/src/metric/benchmark/bench.hpp @@ -36,11 +36,13 @@ void bench_mixed_impl(IMPL& impl, WRITE_OP&& op, size_t thd_num, std::string val(36, ' '); for (size_t i = 0; i < thd_num; i++) { vec.push_back(std::thread([&, i] { - while (!stop) { - bench_clock_t clock; + bench_clock_t clock_loop; + auto dur = clock.duration(); + while (!stop || dur < duration * 2) { op(); - auto t = clock.duration(); - lantency_summary.observe(t.count() / 1000.0f); + auto new_dur = clock.duration(); + lantency_summary.observe((new_dur - dur).count() / 1000.0f); + dur = new_dur; } })); } @@ -55,6 +57,10 @@ void bench_mixed_impl(IMPL& impl, WRITE_OP&& op, size_t thd_num, } while (clock2.duration() < duration); auto total_ms = clock.duration(); stop = true; + if constexpr (requires { impl.size(); }) { + std::cout << "size:" << impl.size() << "\n"; + } + std::cout << "run " << total_ms.count() << "ms\n"; uint64_t cnt; double sum;