function Time;

global devicenum
global Devices Num Queue
global curtime time queuetime worktime TimeCount systemtime
global queueamount workamount sysamount tmpsysusage
global tmpqueuetime tmpworktime tmpqueuetime

TimeCount = TimeCount + 1;

time(TimeCount) = curtime;

  
    counter = 0;
    
    for i=1:length(Queue)
        if Queue(i) ~= 0
            counter = counter+1;
        end;
    end;
    
    queueamount(TimeCount) = counter;


if TimeCount ~= 1
    queuetime = queuetime + (counter*(time(TimeCount) - time(TimeCount-1)));
else 
    queuetime = queuetime + (counter*(time(TimeCount)-0));
end;
   
    counter = 0;
    
    for i= 1:devicenum
        if Devices(i) ~= 0
            counter = counter +1;
        end;
    end;
    
    workamount(TimeCount) = counter;
    
if TimeCount ~= 1
    worktime = worktime + (counter*(time(TimeCount) - time(TimeCount-1)));
else
    worktime = worktime + (counter*(time(TimeCount) - 0));
end;


 
tmpqueuetime(TimeCount) = queuetime;
tmpworktime(TimeCount) = worktime;

if curtime ~= 0
    tmpsysusage(TimeCount) = worktime/(devicenum*curtime);
end;
