From 4045a1ca7d9bbec166b17fdf3228e21fe8f48928 Mon Sep 17 00:00:00 2001 From: Karl Kfoury <76066593+KarlKfoury@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:08:31 +0300 Subject: [PATCH] calculating time elapsed from start to end of nn eval + logging if time > 1s fixing issue #1768 --- src/mcts/search.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mcts/search.cc b/src/mcts/search.cc index 71eb543c10..483dff3d30 100644 --- a/src/mcts/search.cc +++ b/src/mcts/search.cc @@ -2189,7 +2189,15 @@ 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::cerr << "Warning: Computation took " << elapsed.count() << " seconds, which is longer than expected." << std::endl; + } +} // 5. Retrieve NN computations (and terminal values) into nodes. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~