Commit c8b7db83 authored by RomainFeron's avatar RomainFeron
Browse files

Implemented progress bars - why not

parent c6549777
......@@ -96,7 +96,7 @@ void processor(MarkersQueue& markers_queue, Parameters& parameters, std::mutex&
}
log_progress(n_processed_markers, marker_processed_tick);
log_progress_bar(n_processed_markers, marker_processed_tick);
}
......
......@@ -79,7 +79,7 @@ void processor(MarkersQueue& markers_queue, Parameters& parameters, std::mutex&
for (auto marker: batch) {
++results[marker.groups[parameters.group1]][marker.groups[parameters.group2]].first;
log_progress(n_processed_markers, marker_processed_tick);
log_progress_bar(n_processed_markers, marker_processed_tick);
}
......
......@@ -61,7 +61,7 @@ void processor(MarkersQueue& markers_queue, std::mutex& queue_mutex, std::vector
for (auto& marker: batch) {
++frequencies[marker.n_individuals];
log_progress(n_processed_markers, marker_processed_tick);
log_progress_bar(n_processed_markers, marker_processed_tick);
}
} else {
......
......@@ -151,7 +151,7 @@ void processor(MarkersQueue& markers_queue, Parameters& parameters, Popmap& popm
best_alignment[1] = -1;
best_alignment[2] = 0;
log_progress(n_processed_markers, marker_processed_tick);
log_progress_bar(n_processed_markers, marker_processed_tick);
}
} else {
......
......@@ -134,7 +134,7 @@ void process(Parameters& parameters) {
++id;
}
log_progress(n_processed_markers, marker_processed_tick);
log_progress_bar(n_processed_markers, marker_processed_tick);
}
......
......@@ -80,7 +80,7 @@ void processor(MarkersQueue& markers_queue, Popmap& popmap, Parameters& paramete
}
log_progress(n_processed_markers, marker_processed_tick);
log_progress_bar(n_processed_markers, marker_processed_tick);
}
......
......@@ -59,7 +59,7 @@ void processor(MarkersQueue& markers_queue, Popmap& popmap, Parameters& paramete
}
log_progress(n_processed_markers, marker_processed_tick);
log_progress_bar(n_processed_markers, marker_processed_tick);
}
......
......@@ -63,12 +63,11 @@ inline int fast_stoi(const char* str) {
// Log output formatting
template<typename T>
inline void log(T line, const std::string level = LOG_INFO) {
inline void log(T line, const std::string level = LOG_INFO, bool flushline = true) {
char logtime[DTTMSZ];
std::cerr << "[" << print_time(logtime) << "]::" << level << " ";
std::cerr << std::boolalpha << line << std::endl;
std::cerr << "[" << print_time(logtime) << "]::" << level << " " << std::boolalpha << line;
if (flushline) std::cerr << std::endl;
}
......@@ -146,6 +145,7 @@ inline void log_progress(uint64_t& n_processed_markers, const uint32_t marker_pr
}
inline std::string get_runtime(const std::chrono::steady_clock::time_point t_begin) {
std::chrono::steady_clock::time_point t_end = std::chrono::steady_clock::now();
......@@ -156,3 +156,27 @@ inline std::string get_runtime(const std::chrono::steady_clock::time_point t_beg
return runtime;
}
inline void log_progress_bar(uint64_t& n_processed_markers, const uint32_t marker_processed_tick, char symbol = '#', uint16_t ticks = 50) {
uint tick_size = 100 / ticks;;
if (++n_processed_markers % (tick_size * marker_processed_tick) != 0) return; // Not a step
uint16_t progress = n_processed_markers / (tick_size * marker_processed_tick);
std::string bar = "Progress: [";
for(uint i=0; i < ticks; ++i) {
i < progress ? bar += symbol : bar += ' ';
}
bar += "] - " + std::to_string(progress * tick_size) + "% (" + std::to_string(n_processed_markers) + " markers)";
progress < ticks ? bar += '\r' : bar += '\n';
log(bar, LOG_INFO, false);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment