dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #11593
Re: less irritating Progress meter
On Thu, Jan 08, 2009 at 02:46:26PM -0700, Bartosz Sawicki wrote:
> Class Progress is brilliant. I really love it, but sometimes progress
> meter is too talkative for me. I think that if the time needed to
> compute something is very short, we don't need any extra information
> about it. Progress bar should be completely silent in such cases.
>
> On the other hand progress bar is used too rarely. Mesh connectivity
> computation, assembling usually takes a lot of time for bigger meshes.
> It would be great to use Progress in such places.
>
> So I've prepared patch which changes behavior of Progress class. I
> introduced some logical flags which control when to display information.
> Nothing special, but now you can use Progress as much as you want,
> without worry that there will be too much messages.
>
> regrds.
> BArtek
>
> ps.
> Progress class destructor shouldn't display anything. It is inconvenient
> to call destructor when you want to close progress bar.
>
> ps1.
> If user really wants progress bar even when the task takes 1ms, I give
> him new constructor Progress p(string, int, bool always). If last
> argument is true, progress bar always will be displayed.
Would it be better to make it a global option? Something like
dolfin_set("always display progress", true/false);
--
Anders
>
> diff -r 946e884ef099 dolfin/log/Progress.cpp
> --- a/dolfin/log/Progress.cpp Wed Jan 07 23:10:49 2009 +0000
> +++ b/dolfin/log/Progress.cpp Thu Jan 08 14:08:43 2009 -0700
> @@ -17,8 +17,9 @@
> using namespace dolfin;
>
> //-----------------------------------------------------------------------------
> -Progress::Progress(std::string title, unsigned int n)
> - : title(title), n(n), i(0), p_step(0.1), t_step(1.0), p(0), t(0)
> +Progress::Progress(std::string title, unsigned int n, bool always)
> + : title(title), n(n), i(0), p_step(0.1), t_step(1.0), p(0), t(0),
> + always(always), finished(false), displayed(false)
> {
> if (n <= 0)
> error("Number of steps for progress session must be positive.");
> @@ -27,8 +28,21 @@
> t = time();
> }
> //-----------------------------------------------------------------------------
> +Progress::Progress(std::string title, unsigned int n)
> + : title(title), n(n), i(0), p_step(0.1), t_step(1.0), p(0), t(0),
> + always(false), finished(false), displayed(false)
> +{
> + if (n <= 0)
> + error("Number of steps for progress session must be positive.");
> +
> + //LogManager::logger.progress(title, 0.0);
> + t = time();
> +}
> +
> +//-----------------------------------------------------------------------------
> Progress::Progress(std::string title)
> - : title(title), n(0), i(0), p_step(0.1), t_step(1.0), p(0), t(0)
> + : title(title), n(0), i(0), p_step(0.1), t_step(1.0), p(0), t(0),
> + always(always), finished(false), displayed(false)
> {
> //LogManager::logger.progress(title, 0.0);
> t = time();
> @@ -36,10 +50,6 @@
> //-----------------------------------------------------------------------------
> Progress::~Progress()
> {
> - if (this->p == 0.0)
> - LogManager::logger.message(title + " (finished).");
> - else if (this ->p < 1.0)
> - LogManager::logger.progress(title, 1.0);
> }
> //-----------------------------------------------------------------------------
> void Progress::operator=(double p)
> @@ -70,11 +80,18 @@
> const bool t_check = t - this->t >= t_step - DOLFIN_EPS;
>
> // Only update when the increase is significant
> - if (t_check)
> + if (t_check || always || (p >= 1.0 && displayed && !finished))
> {
> LogManager::logger.progress(title, p);
> this->p = p;
> this->t = t;
> + always = false;
> + displayed = true;
> }
> +
> + // Update finished flag
> + if (p >= 1.0)
> + finished = true;
> +
> }
> //-----------------------------------------------------------------------------
> diff -r 946e884ef099 dolfin/log/Progress.h
> --- a/dolfin/log/Progress.h Wed Jan 07 23:10:49 2009 +0000
> +++ b/dolfin/log/Progress.h Thu Jan 08 14:08:43 2009 -0700
> @@ -40,6 +40,9 @@
> public:
>
> /// Create progress bar with a known number of steps
> + Progress(std::string title, unsigned int n, bool always);
> +
> + /// Create progress bar with a known number of steps
> Progress(std::string title, unsigned int n);
>
> /// Create progress bar with an unknown number of steps
> @@ -80,6 +83,15 @@
> // Current time
> double t;
>
> + // Always visible
> + bool always;
> +
> + // Finished flag
> + bool finished;
> +
> + // Displayed flag
> + bool displayed;
> +
> };
>
> }
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
Attachment:
signature.asc
Description: Digital signature
Follow ups
References