From 7b7cc9bf91ed390ccd287cf92549dbd68530abe7 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Mon, 23 Jan 2023 16:43:44 +0800 Subject: [PATCH] build: compile with benchmark module --- src/CMakeLists.txt | 17 +++---- src/benchmark/CMakeLists.txt | 5 +++ src/main.cc | 87 ++++++++++++++++++------------------ 3 files changed, 54 insertions(+), 55 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8067075..e610752 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,18 +1,11 @@ cmake_minimum_required(VERSION 3.0) -#include_directories(klotski) -#include_directories(klotski/utils) -#include_directories(klotski/all_cases) -# -#include_directories(klotski/raw_code) -#include_directories(klotski/short_code) -#include_directories(klotski/common_code) -# -#include_directories(klotski/core) -#include_directories(klotski/analyse) -#include_directories(klotski/fast_cal) +include_directories(klotski) +include_directories(benchmark) add_subdirectory(klotski) +add_subdirectory(benchmark) -#add_executable(klotski_bin main.cc) +add_executable(klotski_bin main.cc) +target_link_libraries(klotski_bin benchmark) #target_link_libraries(klotski_bin klotski) diff --git a/src/benchmark/CMakeLists.txt b/src/benchmark/CMakeLists.txt index b668aa6..d1dc82c 100644 --- a/src/benchmark/CMakeLists.txt +++ b/src/benchmark/CMakeLists.txt @@ -1 +1,6 @@ +cmake_minimum_required(VERSION 3.0) + +include_directories(../klotski/all_cases) + add_library(benchmark chore.cc benchmark.cc) +target_link_libraries(benchmark klotski) diff --git a/src/main.cc b/src/main.cc index 479fd1a..f51feb8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,19 +1,19 @@ #include -#include "common.h" -#include "all_cases.h" - -#include "raw_code.h" -#include "short_code.h" -#include "common_code.h" - -#include "core.h" -#include "analyse.h" -#include "fast_cal.h" +//#include "utils/common.h" +//#include "all_cases/all_cases.h" +// +//#include "raw_code/raw_code.h" +//#include "short_code/short_code.h" +//#include "common_code/common_code.h" +// +//#include "core/core.h" +//#include "analyse/analyse.h" +//#include "fast_cal/fast_cal.h" //#include "graph.h" -//#include "benchmark.h" +#include "benchmark.h" //#include @@ -21,39 +21,40 @@ int main() { std::cout << "start test" << std::endl; - std::cout << (uint32_t)Common::check_range(1, Common::range_reverse(0xA9BF0C00)) << std::endl; - - AllCases::build(); - for (const auto &a : AllCases::fetch()) { - std::cout << a.size() << std::endl; - } - - std::cout << RawCode::from_common_code("1a9bf0c") << std::endl; - std::cout << RawCode::create(0x0603EDF5CAFFF5E2) << std::endl; - - std::cout << CommonCode::create(0x1A9BF0C00) << std::endl; - std::cout << CommonCode::from_string("1a9bf0c") << std::endl; - std::cout << CommonCode::from_short_code(4091296) << std::endl; - std::cout << CommonCode::from_raw_code(0x0603EDF5CAFFF5E2) << std::endl; - - std::cout << ShortCode::create(4091296) << std::endl; - std::cout << ShortCode::from_string("4WVE1") << std::endl; - std::cout << ShortCode::from_common_code(0x1A9BF0C00) << std::endl; - - auto core = Core([](uint64_t code, uint64_t mask) { - printf("new case -> code = %015lX | mask = %015lX\n", code, mask); - }); - core.next_cases(RawCode::from_common_code("1a9bf0c").unwrap(), 0); - - for (const auto &c : FastCal::resolve(RawCode::from_common_code("1a9bf0c"))) { - std::cout << c << std::endl; - } - - auto a = Analyse(RawCode::from_common_code("1a9bf0c")); - for (const auto &s : a.build_resolve()) { - std::cout << s << std::endl; - } +// std::cout << (uint32_t)Common::check_range(1, Common::range_reverse(0xA9BF0C00)) << std::endl; +// +// AllCases::build(); +// for (const auto &a : AllCases::fetch()) { +// std::cout << a.size() << std::endl; +// } +// +// std::cout << RawCode::from_common_code("1a9bf0c") << std::endl; +// std::cout << RawCode::create(0x0603EDF5CAFFF5E2) << std::endl; +// +// std::cout << CommonCode::create(0x1A9BF0C00) << std::endl; +// std::cout << CommonCode::from_string("1a9bf0c") << std::endl; +// std::cout << CommonCode::from_short_code(4091296) << std::endl; +// std::cout << CommonCode::from_raw_code(0x0603EDF5CAFFF5E2) << std::endl; +// +// std::cout << ShortCode::create(4091296) << std::endl; +// std::cout << ShortCode::from_string("4WVE1") << std::endl; +// std::cout << ShortCode::from_common_code(0x1A9BF0C00) << std::endl; +// +// auto core = Core([](uint64_t code, uint64_t mask) { +// printf("new case -> code = %015lX | mask = %015lX\n", code, mask); +// }); +// core.next_cases(RawCode::from_common_code("1a9bf0c").unwrap(), 0); +// +// for (const auto &c : FastCal::resolve(RawCode::from_common_code("1a9bf0c"))) { +// std::cout << c << std::endl; +// } +// +// auto a = Analyse(RawCode::from_common_code("1a9bf0c")); +// for (const auto &s : a.build_resolve()) { +// std::cout << s << std::endl; +// } + Benchmark::basic_ranges(std::cout); std::cout << "end test" << std::endl;