diff options
Diffstat (limited to 'src/uci.cpp')
| -rw-r--r-- | src/uci.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
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 <array> #include <cassert> #include <cctype> +#include <chrono> #include <cstddef> #include <cstdint> #include <cstdlib> @@ -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<std::chrono::milliseconds>(end - start) + .count(); + std::ostringstream oss; + oss << "{\"ms\": " << ms << ", \"result\": " << count << "}"; + + std::cout << oss.str() << "\n"; + } } } |
