diff options
| author | Adam <adammegarules1@gmail.com> | 2026-08-18 14:02:01 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-08-18 14:02:01 +0200 |
| commit | dd4f969d156bbaa546911b3951211bb2245182ad (patch) | |
| tree | 96db81b57721b936bebeafcaab24b84356553904 | |
| parent | 2dbcd83cdb015485e20f54967d88d0dbb9cd2c44 (diff) | |
fix(tests): making zobrist tests use json
| -rwxr-xr-x | scripts/tests/zobrist.bash | 7 | ||||
| -rw-r--r-- | src/main.cpp | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/scripts/tests/zobrist.bash b/scripts/tests/zobrist.bash index 7545f6d..bcfc437 100755 --- a/scripts/tests/zobrist.bash +++ b/scripts/tests/zobrist.bash @@ -10,13 +10,16 @@ testZobrist() { echo "" - result=$(./build/mono zobrist "$fen" $moves) + resultRaw=$(./build/mono zobrist "$fen" $moves) + result=$(echo $resultRaw | jq -r '.hash') + took=$(echo $resultRaw | jq -r '.ms') if [ "$result" = "$expected" ]; then - echo "PASS: $name" + echo "PASS: $name, Took: $took" else echo "FAIL: $name" echo " Expected: $expected" echo " Got: $result" + echo " Raw: $resultRaw" status=1 fi } diff --git a/src/main.cpp b/src/main.cpp index dd30306..c3945d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,8 +58,16 @@ static void zobristCmd(int argc, char *argv[]) { MakeMove(move, &game); } + auto start = std::chrono::steady_clock::now(); + uint64_t hash = GenerateZobristKey(&game); - std::cout << hash << "\n"; + 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 << ", \"hash\": " << hash << "}"; + + std::cout << oss.str() << "\n"; } int main(int argc, char *argv[]) { |
