All articles in the Software category

Automated notifications in C++ loops

6 Comments
Posted February 26th, 2009 in Software. Tags: , .

As a computational physicist, I’m often running programs that consist of many nested for-loops. At the moment, my outermost loop cycles through millions of data points and various inner loops explore tens of thousands of parameters. I’m always fiddling with the settings on the inner loops in ways that cause the run time to vary between 10 seconds and 10 weeks.

Annoyingly, it’s not always easy to predict how long the program will run after each set of modifications. Also, my code occasionally has bugs which make it hang indefinitely. When a program’s expected run time is measured in weeks, it’s reassuring to see regular progress reports. Otherwise I worry that the program has silently crashed.

At first I just slapped a print statement into the outermost for-loop, encased in an if-then statement which only activated once every 1000 loops. The print statement used the time elapsed since the start of the loop and the progress made to estimate the time remaining. It looked a little like this (plus some type casting): (more…)

.
.
.

Switch to our mobile site