View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 135 KB File ID: #27472 Version:




04 May 2010 (Updated )

This is a utility for timing PARFOR loops.

| Watch this File

File Information

This utility is a class for timing PARFOR loops. It can be used to observe the various overheads that may exist in parallel for loops and the utilization of each worker. Various examples of using this utility can be found in Example_Script.m.
This class should be used in the following way:
        p = Par(n); (1)
        parfor id = 1:n
            Par.tic; (2)
            <usual computations>
            p(id) = Par.toc; (3)
        stop(p); (4)
        plot(p); (5)
  1. Construct a Par object, with the number of iterations as the input. This constructs the object.
  2. Call Par.tic just inside the PARFOR loop. This records the start time of the iteration.
  3. Call Par.toc just before the end of the PARFOR loop. Store the
output to the appropriate index of the Par object. This is necessary for PARFOR to recognize that the variable is sliced.
  4. Stop the measurement. This records the final end time.
  5. Visualize.
There may be some overhead in adding the Par construct. Because of this, the numbers you get may not accurately portray the true timing, especially for short computations.

Required Products Parallel Computing Toolbox
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
11 Oct 2016 Charalampos Kyriakopoulos

I am running matlab R2016a and i am getting this error: "Unable to convert objects of class 'Par' into 'double'." in the parfor line. Any ideas?

Comment only
02 Jul 2015 Anton Semechko

Anton Semechko (view profile)

31 Jul 2013 Sebastian

Sebastian (view profile)

Sorry, I wrote wrong:
*Change (Line 592 to 594):
newlabels = char(zeros(length(ylabels),6));
newlabels(:,1) = ylabels;
newlabels(1,:) = 'Serial';

Comment only
31 Jul 2013 Sebastian

Sebastian (view profile)

Great program!
I think has a bug when is used with plot(obj,obj2) option and is utilized with 10 o more workers.
I fixed this problem with:
*Change (Line 592 and 593):
newlabels = char(zeros(length(ylabels),6));
newlabels(:,1) = ylabels;
serTex = 'Serial';
carSerTex = length(serTex);
carYLab = size(ylabels,2);
newlabels = char(zeros(length(ylabels),max(carSerTex,carYLab)));
newlabels(:,1:carYLab) = ylabels;
newlabels(1,1:carSerTex) = serTex;

Comment only
18 Oct 2010 Eric Johnson

This is the best PARFOR profiling tool I've found.

01 Sep 2016

Updated license

Contact us