bcobo / SIRENA

https://bcobo.github.io/SIRENA/
GNU General Public License v3.0
0 stars 0 forks source link

Progress bar in gennoisespec crashes with new version of boost (progress.hpp is deprecated) #28

Closed mtceballos closed 1 month ago

mtceballos commented 1 month ago

It could be replaced by a standard C++ function:

void show_progress(int current, int total) { int width = 100; // Ancho de la barra de progreso int progress = (width * current) / total;

std::cout << "["; for (int i = 0; i < progress; ++i) std::cout << "#"; for (int i = progress; i < width; ++i) std::cout << " "; std::cout << "] " << (100 * current / total) << "%\r"; //std::cout.flush(); std::cout << std::flush; }

and then call it inside the appropriate loop as: show_progress(current, total)

mtceballos commented 1 month ago

In addition there is no clear place where to locate the counter for the progress bar:

1) If (as it is currently in version 10.2.0) it is inside the loop for (int k=0; k<nIntervals;k++)of inDataIterator, progress bar exceeds 100% as it is limited by the number of intervals. However 'nIntervals' is smaller than the number of of times the progress bar is updated, which is equal to Number_of_calls_to_inDataIterator*nintervals

2) If it is inside inDataIterator, there is no way of knowing how many calls to inDataIterator will be produced

Is there any other loop where the progress can be established?

bcobo commented 1 month ago

Removed include corresponging to progress.hpp.

New code for progress bar included in inDataIterator. It works by using NumMeanSamples and totalrows to run the progress bar: // Progress bar float progress = (float)NumMeanSamples / (totalrows-1); int bar_width = 50; int pos = bar_width progress; printf("Generating the noise spectrum |"); for (int j = 0; j < bar_width; j++) { if (j < pos) printf("="); else if (j == pos) printf(">"); else printf(" "); } printf("| %.2f%%\r", progress 100); fflush(stdout); if (NumMeanSamples == totalrows-1) { printf("\n"); // New line after ending "Generating the noise spectrum...." }

mtceballos commented 1 month ago

Closed in commit d8ad4963d57acf7397c92839c1de32f86a4e8c51