matlab实现用于循环计时的类

收录时间:2021-09-13
资源分类:Matlab 工具:MATLAB 7.10 (R2010a)

此实用程序是用于循环计时的类。它可用于观察回路中可能并行存在的各种开销以及每个工人的利用率。可以在示例_Script.m中找到使用此实用程序的各种示例。

parTicToc

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)

  

            

  

            p(id) = Par.toc; (3)

        end

        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.

文件下载列表
parTicToc.zip (134.94KB)  
附件内容(只显示12中的3个)
Example_Script.m  Par.m  sweepExample.m  
更多

目前尚无评论

用户反馈   关于我们
Copyright (©) ZHIHUISHI.COM 2013 All Rights Reserved.
京ICP备18060134号-3