From 8287ac739a45edc32c972876103043292d06b308 Mon Sep 17 00:00:00 2001 From: rektdie Date: Wed, 2 Apr 2025 00:20:06 +0200 Subject: [PATCH] printing thread count --- source/datagen.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/datagen.cpp b/source/datagen.cpp index 3a71e77..ec537df 100644 --- a/source/datagen.cpp +++ b/source/datagen.cpp @@ -150,7 +150,7 @@ static void WriteToFile(const Game &game, const std::string &filename) { file.close(); } -void PrintProgress(int positions, int targetPositions, Stopwatch &stopwatch) { +void PrintProgress(int positions, int targetPositions, Stopwatch &stopwatch, int threads) { double elapsed = stopwatch.GetElapsedSec(); double positionsPerSec = elapsed > 0 ? positions / elapsed : 0; @@ -190,6 +190,12 @@ void PrintProgress(int positions, int targetPositions, Stopwatch &stopwatch) { std::cout << std::endl; + std::string threadsText = "Threads: " + std::to_string(static_cast(threads)); + int threadsTextPadding = (width - threadsText.length()) / 2; + std::cout << std::setw(threadsTextPadding + threadsText.length()) << threadsText << std::endl; + + std::cout << std::endl; + int barWidth = 50; double progress = (double)positions / targetPositions; int pos = (int)(progress * barWidth); @@ -268,7 +274,7 @@ void Run(int targetPositions, int threads) { if (positions / 100 > lastPrintedPosition) { lastPrintedPosition = positions / 1000; - PrintProgress(positions, targetPositions * 1000000, stopwatch); + PrintProgress(positions, targetPositions * 1000000, stopwatch, threads); } }