Code covered by the BSD License  

Highlights from
Job Estimator

image thumbnail

Job Estimator

by

 

21 Nov 2006 (Updated )

Estimates how long a job will take on a comput cluster of various sizes

jobEstimate(taskLengths, efficiency, numWorkers)
function job = jobEstimate(taskLengths, efficiency, numWorkers)

if nargin == 2
    numWorkers = efficiency;
    efficiency = ones(size(taskLengths)); 
end

if numel(efficiency) == 1
    efficiency = efficiency * ones(size(taskLengths));
end

if min(taskLengths) <= 0
    error('TaskLengths must be greater than zero.')
end

if (min(efficiency) <= 0) || (max(efficiency) > 1)
    error('Efficiency must be >0 and <=1')
end

taskStart = zeros(1, numel(taskLengths));
taskEnd   = zeros(1, numel(taskLengths));
worker    = zeros(1, numel(taskLengths));
firstIdle = zeros(1, numWorkers);

for i = 1 : numel(taskLengths)
    [val, worker(i)] = min(firstIdle);
    taskStart(i) = firstIdle(worker(i)) + ((1-efficiency(i)) * taskLengths(i));
    firstIdle(worker(i)) = taskStart(i) + taskLengths(i);
    taskEnd(i)   = firstIdle(worker(i));
end

job.DeltaTime  = max(firstIdle);
job.StartTime  = locMakeJavaTime(0);
job.FinishTime = locMakeJavaTime(job.DeltaTime);

job.State      = 'finished';

for i = 1 : numel(taskLengths)
    job.Tasks(i).Worker.Name = ['Worker_' num2str(worker(i))];
    job.Tasks(i).StartTime   = locMakeJavaTime(taskStart(i));
    job.Tasks(i).FinishTime  = locMakeJavaTime(taskEnd(i));
end 
    
function javaTime = locMakeJavaTime(relTime)

sec2fracDay = 1/(24*60*60);
timeString = datestr(relTime * sec2fracDay, 'mmm dd HH:MM:ss yyyy');

javaTime = ['Mon ' timeString(1:15) ' EDT ' timeString(17:20)];
% Copyright 2007 - 2009 The MathWorks, Inc.
    

Contact us