Skip to content

Commit

Permalink
Merge pull request #96 from pynbody/lustre-performance
Browse files Browse the repository at this point in the history
Neaten behaviour of progress bar
  • Loading branch information
apontzen authored Aug 9, 2021
2 parents e17bf6c + fb24ea4 commit 9996bfd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ GenetIC is a code to generate initial conditions for cosmological simulations, e
* The main code is written in C++ and can be found (with build instructions and a test suite) in the subfolder `genetIC`.
* The code is also available as [docker](http://docker.io) image `apontzen/genetic` (see the user manual for further information)
* A set of python tools for development and testing is provided in `tools`.
* If you wish to use the code for science, we recommend adopting a particular version. The current release is v1.3 and can be downloaded at https://github.com/pynbody/genetIC/releases/tag/v1.3
* Documentation can be found in the form of a PDF user manual, also at https://github.com/pynbody/genetIC/releases/tag/v1.3
* If you wish to use the code for science, we recommend adopting a particular (numbered) version. The most recent release can be downloaded at https://github.com/pynbody/genetIC/releases/latest
* Documentation can be found in the form of a PDF user manual, also at https://github.com/pynbody/genetIC/releases/latest
* The technical underpinnings of the code are described in a release paper at https://arxiv.org/abs/2006.01841

License and acknowledgement policy
Expand Down
2 changes: 1 addition & 1 deletion genetIC/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void setup_parser(tools::ClassDispatch<ICf, void> &dispatch) {
}

void header(ostream &outf, std::string prefix="") {
outf << prefix << "genetIC v1.3.0, compiled: " << __DATE__ << ", " << __TIME__ << endl;
outf << prefix << "genetIC v1.3.1, compiled: " << __DATE__ << ", " << __TIME__ << endl;
time_t now = time(0);
struct tm tstruct;
char buf[80];
Expand Down
12 changes: 9 additions & 3 deletions genetIC/src/tools/progress/progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <sys/ioctl.h>
#include <unistd.h>

#include "src/tools/logging.hpp"
#include "progress.hpp"

namespace tools {
Expand All @@ -17,7 +18,7 @@ namespace tools {
return size_t(size.ws_col);
}

//! Returns true if the terminal display is wider than 0
//! Returns true if stdout is believed to be a terminal display
bool ProgressBar::isInteractive() {
return terminalWidth() > 0;
}
Expand All @@ -42,7 +43,7 @@ namespace tools {
stream << "\r";
}

//! Update the display if possible
//! Update the display if stdout is a terminal
void ProgressBar::update() {
if (!isInteractive())
return;
Expand Down Expand Up @@ -94,7 +95,8 @@ namespace tools {
update();
}
update();
stream << std::endl;
if(isInteractive())
stream << std::endl;
}


Expand All @@ -104,6 +106,8 @@ namespace tools {
terminated = true;
cv.notify_all();
thread.join();
if(!isInteractive() && !title.empty())
logging::entry() << "Finished " << title << std::endl;
}

//! Updates the progress variable
Expand All @@ -122,6 +126,8 @@ namespace tools {
nOpsCurrent = 0;
terminated = false;
thread = std::thread([this]() { this->runUpdateLoop(); });
if(!isInteractive() && !title.empty())
logging::entry() << "Starting " << title << std::endl;
}

//! Destructor - terminates progress bar if still in progress.
Expand Down

0 comments on commit 9996bfd

Please sign in to comment.