I'd like to have some way to view the time elapsed since the beginning of a long evaluation, viewable while the computation is still evaluating.
My first thought was to use Monitor
, but it seems to require a variable's value to update before updating the display. That is, I can't just provide it an expression I'd like re-evaluated 'continuously' throughout the computation:
With[{start=Now},
Monitor[
Table[Length[FactorInteger[2^n - 1]], {n, 50, 450, 50}],
DateDifference[start, Now, "Second"]
]
]
(Example computation slightly modified from the first example in the docs for Monitor
.) During evaluation, the Monitor
cell never updates from its initial value -- see above.
Fine -- looks like I was expecting Monitor
to do something it doesn't. One would expect it to be difficult for such a function to determine how often to re-evaluate the expression to be monitored anyway.
Then the question becomes whether there's a way to do what I wanted Monitor
to do -- evaluate an expression 'continuously' and display its updated value.
Of course, I don't really want this function updated continuously -- just every second or 10th of a second or so, ideally with a configurable duration. Obviously I don't want this monitoring to slow down my computation in any non-neglible sense.
Note in particular that I do not wish to modify the expression being monitored to provide any sort of report on its progress, or anything like that. I want this method to track the evaluation of an arbitrary expression.
Monitor
. $\endgroup$PrintTemporary@Dynamic@{mr, Clock[Infinity]};
about halfway down), and just after posting it, I saw your Q&A. $\endgroup$