From 22718aea57fde4e325aea4c0d36d76b0d1609fa7 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 Aug 2026 10:30:53 +0200 Subject: refactor(tests): improving tests by creating testing cli app --- src/uci.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/uci.cpp') diff --git a/src/uci.cpp b/src/uci.cpp index 7cff997..5f62169 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -351,5 +352,35 @@ void Uci() { uint64_t hash = GenerateHashFromScratch(&game); std::cout << hash << "\n"; } + if (cmd.starts_with("perft")) { + + uint32_t depth = 0; + + std::stringstream ss(cmd); + std::string token; + + ss >> token; // position + + ss >> depth; + + auto start = std::chrono::steady_clock::now(); + + uint64_t count = 0; + +#ifdef PERFT_DIVIDE + count = MoveGenTestDivide(depth, &game); +#else + count = MoveGenTest(depth, &game); +#endif + + auto end = std::chrono::steady_clock::now(); + auto ms = + std::chrono::duration_cast(end - start) + .count(); + std::ostringstream oss; + oss << "{\"ms\": " << ms << ", \"result\": " << count << "}"; + + std::cout << oss.str() << "\n"; + } } } -- cgit v1.2.3