From 532b1762fac74c4df67e37b1174fb3a786d89930 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 19 Feb 2023 15:47:22 +0800 Subject: [PATCH] perf: short code verify --- test/global/global_utils.h | 1 + test/global/short_code.cc | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/global/global_utils.h b/test/global/global_utils.h index 05aee9f..602af02 100644 --- a/test/global/global_utils.h +++ b/test/global/global_utils.h @@ -24,6 +24,7 @@ public: void kill() { tiny_pool_kill(pool); } void detach() { tiny_pool_detach(pool); } explicit TinyPool(uint32_t size) { pool = tiny_pool_create(size); } + // TODO: thread pool destroy template auto submit(Func &&func, Args &&...args) -> std::future { // submit new task diff --git a/test/global/short_code.cc b/test/global/short_code.cc index 89418f5..eb026fc 100644 --- a/test/global/short_code.cc +++ b/test/global/short_code.cc @@ -17,17 +17,11 @@ std::vector short_code_check(uint32_t start, uint32_t end) { return archive; } -TEST(GLOBAL, short_code) { +void short_code_verify() { /// create short code check tasks auto pool = TinyPool(thread_num()); - ShortCode::speed_up(ShortCode::NORMAL); std::vector>> futures; - for (const auto &range : range_split(0, klotski::ALL_CASES_SIZE_SUM, 10000)) { -// for (const auto &range : range_split(0, 80000, 10000)) { - -// std::cout << "[" << range.first << ", " << range.second << ")" << std::endl; - futures.emplace_back( pool.submit(short_code_check, range.first, range.second) ); @@ -42,8 +36,6 @@ TEST(GLOBAL, short_code) { } pool.join(); -// std::cout << result.size() << std::endl; - /// verify check result std::vector all_cases; for (uint64_t head = 0; head < 16; ++head) { @@ -52,5 +44,12 @@ TEST(GLOBAL, short_code) { } } EXPECT_EQ(result, all_cases); +} + +TEST(GLOBAL, short_code) { + ShortCode::speed_up(ShortCode::NORMAL); // normal mode + short_code_verify(); + ShortCode::speed_up(ShortCode::FAST); // fast mode + short_code_verify(); }