# Progress bar / counter for multi-row table with 2 variables

I have a table that takes a long time to calculate because f[x] is quite a complicated function:

Table[f[x], {m, 50, 1000, 50}, {x, 0, 50}]


It would be great to have a progress bar to give some idea of how long the evaluation will take to complete. Ideally, I would also like a counter stating which values of m and x are currently being assessed.

This thread offers a simple progress bar:

Monitor[
Table[Pause[0.1]; Prime[i], {i, 100}],
Row[{ProgressIndicator[i, {1, 100}], i}, " "]
]


But I can't figure out how to adapt this for a multi-row table with two variables, or how to produce a counter that tells me what values of m and x are currently being evaluated.

I'd be very grateful for any solutions.

• Monitor[ Table[Pause[0.01]; Prime[m x], {m, 50, 1000, 50}, {x, 1, 50}], Grid[{ {"Total progress:", ProgressIndicator[Dynamic[m/1000]]}, {"Current row progress:", ProgressIndicator[Dynamic[x/50]]}, {"{m, x}=", {Dynamic@m, Dynamic@x}} }] ]?
– Kuba
May 16 '18 at 19:07

How about a simple method such as this. You can easily adjust as needed. It hard to guess how long it will take each step. This assumes each step takes same amount of time. This is how ProgressIndicator works.

ClearAll[n, m, p];
f[n_] := FactorInteger[2^n - 1];

nRows = 10;
nCols = 20;
total = nRows*nCols;
p = 0;

Grid[{
{Row[{"row ", Dynamic@m, " column ", Dynamic@n}]},
{ProgressIndicator[Dynamic[p], {1, total}]}
}]

Do[
Do[
p += 1;
f[p],
{m, 1, nRows}
],
{n, 1, nCols}
]


now

• Thanks for both suggestions. I'm away from my computer iuntil morning now, but will report back. May 16 '18 at 19:14
• Both of these work. I can only tick the one that's proposed as an answer, though. Much appreciated. May 17 '18 at 7:38