Class to monitor progress of parfor loop
The parallel workers write to a common file for each iteration and determine the total number of completed iterations by counting the number of lines in the file.
pp = ParforProgress;
parfor kk = 1:100
iteration_number = step(pp, kk);
fprintf('Finished iteration %d of %d\n', iteration_number, kk);
The numbers may not go exactly in order depending on the order in which the parallel workers finish, but they'll be close enough so you'll get the idea of where you are.
The technique of using a single file to store the iteration information was inspired
by this file exchange utility:
Daniel Golden (2023). ParforProgress class (https://github.com/dgolden1/ParforProgress), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Versions that use the GitHub default branch cannot be downloaded
Correct description of algorithm