printing thread count
This commit is contained in:
1 parent
ac2b8cc0a4
commit
8287ac739a
1 file changed
+8
-2
+8
-2
@@ -150,7 +150,7 @@ static void WriteToFile(const Game &game, const std::string &filename) {
|
|||||||
file.close();
|
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 elapsed = stopwatch.GetElapsedSec();
|
||||||
double positionsPerSec = elapsed > 0 ? positions / elapsed : 0;
|
double positionsPerSec = elapsed > 0 ? positions / elapsed : 0;
|
||||||
|
|
||||||
@@ -190,6 +190,12 @@ void PrintProgress(int positions, int targetPositions, Stopwatch &stopwatch) {
|
|||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
std::string threadsText = "Threads: " + std::to_string(static_cast<int>(threads));
|
||||||
|
int threadsTextPadding = (width - threadsText.length()) / 2;
|
||||||
|
std::cout << std::setw(threadsTextPadding + threadsText.length()) << threadsText << std::endl;
|
||||||
|
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
int barWidth = 50;
|
int barWidth = 50;
|
||||||
double progress = (double)positions / targetPositions;
|
double progress = (double)positions / targetPositions;
|
||||||
int pos = (int)(progress * barWidth);
|
int pos = (int)(progress * barWidth);
|
||||||
@@ -268,7 +274,7 @@ void Run(int targetPositions, int threads) {
|
|||||||
|
|
||||||
if (positions / 100 > lastPrintedPosition) {
|
if (positions / 100 > lastPrintedPosition) {
|
||||||
lastPrintedPosition = positions / 1000;
|
lastPrintedPosition = positions / 1000;
|
||||||
PrintProgress(positions, targetPositions * 1000000, stopwatch);
|
PrintProgress(positions, targetPositions * 1000000, stopwatch, threads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user