Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit bfaa0724 authored by Quentin Khan's avatar Quentin Khan
Browse files

PerfTest descriptor: extract the progress bar from the loader

parent 991f5abd
......@@ -304,43 +304,54 @@ struct uniform_tree_descriptor {
// Basic loader descriptor ///////////////////////
#include "Files/FFmaGenericLoader.hpp"
#include <thread>
struct progress_bar {
std::stringstream sstr;
std::thread t;
progress_bar() {
this->sstr.precision(3);
}
template<typename Loader>
void follow(FSize& idx, Loader& l) {
this->t = std::thread(
[this,&idx,&l]() {
bool run = true;
while(run) {
sstr.str("");
sstr.clear();
sstr.precision(4);
double p = static_cast<double>(idx) * 100.
/ static_cast<double>(l.getNumberOfParticles());
sstr << "Loading particles: [";
for(double i = 0; i < 100; i += 7.5) {
sstr << (i < p ? '|' : ' ');
}
sstr << "] " << p << "% ";
std::cout << '\r' << sstr.str() << std::flush;
run = idx < l.getNumberOfParticles();
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
});
}
void finish() {
this->t.join();
}
};
#include "Files/FFmaGenericLoader.hpp"
template<typename FReal>
struct default_loader_descriptor {
struct loader_t : public FFmaGenericLoader<FReal> {
std::stringstream sstr;
std::thread t;
void setup_progress(FSize& idx) {
this->t = std::thread(
[this,&idx]() {
bool run = true;
while(run) {
sstr.str("");
sstr.clear();
sstr.precision(4);
double p = static_cast<double>(idx) * 100.
/ static_cast<double>(this->getNumberOfParticles());
sstr << "Loading particles: [";
for(double i = 0; i < 100; i += 7.5) {
sstr << (i < p ? '|' : ' ');
}
sstr << "] " << p << "% ";
std::cout << '\r' << sstr.str() << std::flush;
run = idx < this->getNumberOfParticles();
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
});
}
progress_bar progress;
loader_t(const FPerfTestParams& params)
: FFmaGenericLoader<FReal>(params.filename){
this->sstr.precision(3);
}
template<typename tree_t>
......@@ -351,7 +362,7 @@ struct default_loader_descriptor {
FPoint<FReal> position;
FReal physicalValue = 0.0;
this->setup_progress(idxPart);
progress.follow(idxPart,*this);
for(idxPart = 0 ; idxPart < this->getNumberOfParticles() ; ++idxPart){
// Read particle per particle from file
......@@ -359,7 +370,7 @@ struct default_loader_descriptor {
// put particle in octree
tree.insert(position, idxPart, physicalValue);
}
this->t.join();
progress.finish();
std::cout << "done." << std::endl;
}
};
......
Markdown is supported
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