From 3871405cc6d36fef7f56cbc484bebbf3df308ea6 Mon Sep 17 00:00:00 2001 From: Karl Kfoury <76066593+KarlKfoury@users.noreply.github.com> Date: Sat, 31 Aug 2024 17:01:23 +0300 Subject: [PATCH] calculating neural network evaluation time and logging a message if time > 1s adressing issue #1768 --- src/mcts/search.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mcts/search.cc b/src/mcts/search.cc index 71eb543c10..7e848ae7b6 100644 --- a/src/mcts/search.cc +++ b/src/mcts/search.cc @@ -2189,7 +2189,16 @@ int SearchWorker::PrefetchIntoCache(Node* node, int budget, bool is_odd_depth) { // 4. Run NN computation. // ~~~~~~~~~~~~~~~~~~~~~~ -void SearchWorker::RunNNComputation() { computation_->ComputeBlocking(); } +void SearchWorker::RunNNComputation() { + auto start_time = std::chrono::high_resolution_clock::now(); + computation_->ComputeBlocking(); + auto end_time = std::chrono::high_resolution_clock::now(); + std::chrono::duration elapsed = end_time - start_time; + if (elapsed.count() > 1.0) { + std::cout << "Warning: Computation took " << elapsed.count() << " seconds, which is longer than expected." << std::endl; + } + +} // 5. Retrieve NN computations (and terminal values) into nodes. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~