For the *By-type function, ResourceFunction["MonitorProgress"] will monitor only the progress of applying the function to the individual items. Anything else, e.g. the actual sorting, is not included.
For the functions listed in "operator forms", ResourceFunction["MonitorProgress"] will return an operator if the expression was an operator form.
For some types of expressions, ResourceFunction["MonitorProgress"] cannot determine the number of expected steps. In these cases, an "endless" progress bar is used.
ResourceFunction["MonitorProgress"] accepts the following options:
only include timing information if the total number of steps is known
The timing information provided includes time elapsed, time per step, estimated time remaining and estimated total time. The latter two are missing if the number of steps is unknown.
The option "CurrentDisplayFunction" can be set to the following:
The function specified by "CurrentDisplayFunction" is effectively applied to the value set by ResourceFunction["MonitorProgress"]["SetCurrent"]/ResourceFunction["MonitorProgress"]["SetCurrentBy"].
ResourceFunction["MonitorProgress"] supports parallelized evaluation, with the progress being properly synchronized between kernels. The exact behavior can be specified using the Parallelization option:
attempt parallelization using Parallelize; equivalent to {}
If Parallelization→Automatic is specified, any parallelization options specified in expr are taken into account.
If ResourceFunction["MonitorProgress"] cannot automatically determine how to inject tracking into the evaluated expression, the necessary information can be provided manually. Apart from supplying the number of steps expected, it is also necessary to indicate when each step of the computation is finished. It is also possible to set a label for the currently processed item/step. The following functions can be used for this purpose:
set the label of the current step to func[expr];
returns expr
All three functions for manual monitoring return their arguments to allow for simple chaining.
If the number of steps is unknown, Indeterminate can be specified for steps instead. This causes an "endless" progress bar to be used.
ResourceFunction["MonitorProgress"] supports advanced evaluation control and will work nicely with Unevaluated arguments and functions with HoldAll and related attributes.
ResourceFunction["MonitorProgress"] will accurately predict the number of steps needed for mapping operations on SparseArray expressions.
Even though ResourceFunction["MonitorProgress"] is designed to incur minimal overhead, the performance impact might not be negligible if the individual steps are very fast. Furthermore, ResourceFunction["MonitorProgress"] might prevent automatic compilation performed by some functions.
In some cases, the total number of steps is not known:
In[3]:=
Out[3]=
Out[5]=
Scope (6)
Create an operator for later use:
In[6]:=
Out[6]=
Apply the operator to a list:
In[7]:=
Out[7]=
Out[7]=
Indicate steps manually for cases where they cannot be automatically inferred:
In[8]:=
Out[8]=
MonitorProgress supports advanced evaluation control and does not evaluate any arguments to functions with Hold attributes:
In[9]:=
Out[9]=
Out[11]=
Mapping operations on SparseArray expressions are also supported, and the correct number of steps is determined:
In[12]:=
Out[12]=
Out[12]=
MonitorProgress will attempt to construct tracked operators out of Query expressions:
In[13]:=
Out[13]=
In[14]:=
Out[14]=
Out[14]=
Monitor a Dataset query without having to wrap the whole argument explicitly in MonitorProgress@Query[…]:
In[15]:=
Out[15]=
Out[15]=
Options (18)
CurrentDisplayFunction (7)
With the default setting "CurrentDisplayFunction"→Full, a short version of the current item is displayed with a tooltip of the full item:
In[16]:=
Out[16]=
Do not include the tooltip:
In[17]:=
Out[17]=
Do not display the current item at all (this can improve performance for complex items):
In[18]:=
Out[18]=
Use a custom function to generate the expression to display:
In[19]:=
Out[19]=
Use a custom function to generate the expression to display, but do not include a tooltip:
In[20]:=
Out[20]=
Use a different function to generate the tooltip content:
In[21]:=
Out[21]=
Show the full, unmodified current item in the tooltip:
In[22]:=
Out[22]=
Label (2)
With the default setting "Label"→None, no label is included:
In[23]:=
Out[23]=
Out[23]=
Set a custom label for the progress indicator:
In[24]:=
Out[24]=
Out[25]=
Parallelization (3)
With the default setting Parallelization→Automatic, parallelization support is only enabled for explicitly parallelized computations:
In[26]:=
Out[26]=
In[27]:=
Out[27]=
Attempt explicit parallelization using the specified options:
In[28]:=
Out[28]=
This is equivalent to explicitly wrapping the argument in Parallelize[…,opts]:
In[29]:=
Out[29]=
Attempt parallelization using the default settings:
In[30]:=
Out[30]=
Resolution (3)
With the default setting "Resolution"→Automatic, the progress bar is updated 20 times:
In[31]:=
Out[31]=
Update the progress bar only five times:
In[32]:=
Out[32]=
Update the progress bar after every single step:
In[33]:=
Out[33]=
Timing (3)
With the default setting "Timing"→True, timing information is included in all progress indicators:
In[34]:=
Out[34]=
Use "Timing" →Automatic to enable timing only when the total number of steps is known:
In[35]:=
Out[35]=
Disable timing in all cases:
In[36]:=
Out[36]=
Out[37]=
Possible Issues (7)
MonitorProgress computes the total time needed based on the average of all previous steps, which leads to inaccurate predictions for highly variable step durations:
In[38]:=
Out[38]=
Timing information can be disabled in these cases:
In[39]:=
Out[39]=
Although MonitorProgress will return an operator for arbitrary Function expressions, the resulting expression must still be supported by MonitorProgress:
In[40]:=
Out[40]=
In[41]:=
Out[41]=
MonitorProgress does not support all types of Query expressions:
In[42]:=
Out[42]=
MonitorProgress tracks queries by effectively applying Normal to them. This means that certain special behaviors of Query may not be faithfully reproduced:
In[43]:=
Out[16]=
In[44]:=
Out[44]=
In[45]:=
Out[45]=
Although the overhead of MonitorProgress is low, it might not be negligible in all cases:
In[46]:=
In[47]:=
Out[47]=
Very extreme cases of slowdown occur when the untracked operation could be automatically compiled, since the tracking prevents this auto-compilation:
In[48]:=
Out[48]=
In[49]:=
Out[49]=
Parallelization might fail if the underlying operation cannot be parallelized: