If I'm generating a table from a slow function, like this:
foo = Table[SuperSlowExpression, {1000}]
is there a way to determine after submission (so it is too late to instrument the call) to find out how many values already have been generated (so that when it takes longer than expected I can find out whether to wait a bit longer or to abort the calculation)?
So is there still a way to get at the information? Note that there is no iteration variable in the call which I could read.
Optimally, I'd also want to get the already calculated values, of course.
Edit:
Since this seems to have been consistently overlooked:
This is about a calculation which is already running. It is no longer possible to make changes to the call of Table or to the expression inside.
Answer
Given your current situation, there is another option that might help if you have set "Enable notebook history tracking" in Preferences > Advanced:

Then, you go to Cell > Notebook history and navigate to your currently evaluating cell and look at the time stamp when you last edited it. Chances are that you edited it just prior to evaluating (note that if you open an old notebook and execute the cell right away, this might not work, because the last edit timestamp will not be what you want it to be).

Now find the current time from your system clock. Assuming you know how long it takes for one evaluation of SuperSlowExpression, you can now simply do:
$$\mathrm{approx\ progress=\frac{current\ time - last\ edited\ time}{time\ for\ one\ evaluation}}$$
This will give you a rough estimate of the progress — enough to make a decision whether to wait a bit longer or to give up.
Remember, this should be a last ditch option! There are many ifs and buts here, but seeing as all the other options require an iterator and you don't have one (and your Table is running), it's worth trying...
Comments
Post a Comment