您可以使用tic/toc和作业属性很容易地进行调试。请参阅下面的例子
clc; close all; clear;
a = 10;
tic;
c = parcluster();
fprintf('Creating the cluster: %.2f sec\n', toc);
tic;
job = createJob(c);
fprintf('Creating a job: %.2f sec\n', toc);
tic;
createTask(job, @exp, 1, {a});
createTask(job, @sin, 1, {a});
fprintf('Creating the tasks: %.2f sec\n', toc);
tic;
submit(job);
fprintf('Submitting the job: %.2f sec\n', toc);
% Most of the time goes on scheduling the job here
% pause(10);
tic;
wait(job)
fprintf('Waiting time: %.2f sec\n', toc);
tic;
results = fetchOutputs(job);
fprintf('Fetching Results: %.2f sec\n\n', toc);
fprintf('Job Properties\n');
fprintf('Create Time: %s \n', job.CreateTime);
fprintf('Submit Time: %s \n', job.SubmitTime);
fprintf('Start Time: %s \n', job.StartTime);
fprintf('Finish Time: %s \n', job.FinishTime);
delete(job);
如果我跑,我得到以下
Creating the cluster: 0.01 sec
Creating a job: 0.02 sec
Creating the tasks: 0.04 sec
Submitting the job: 0.19 sec
Waiting time: 4.13 sec
Fetching Results: 0.02 sec
Job Properties
Create Time: Mon May 22 10:30:23 BST 2017
Submit Time: Mon May 22 10:30:23 BST 2017
Start Time: Mon May 22 10:30:26 BST 2017
Finish Time: Mon May 22 10:30:27 BST 2017
你看,大部分的时间提交,并开始之间丢失。执行本身非常快。如果您通过从pause(10)
注释引进暂停,您会收到以下
Creating the cluster: 0.01 sec
Creating a job: 0.02 sec
Creating the tasks: 0.04 sec
Submitting the job: 0.19 sec
Waiting time: 0.06 sec
Fetching Results: 0.02 sec
Job Properties
Create Time: Mon May 22 10:31:44 BST 2017
Submit Time: Mon May 22 10:31:44 BST 2017
Start Time: Mon May 22 10:31:47 BST 2017
Finish Time: Mon May 22 10:31:48 BST 2017
因此,当作业被调度和运行,你能想到的早期提交的作业在你的代码,做一些其他的操作,然后在代码中进一步获取结果。我希望这是有帮助的。
感谢您的帮助!我会检查出来〜 – Jason