Throughput of certain number of packets

Hi,
iam trying to find the throughput for 500 packets. this my code:

virtual function void build_phase (uvm_phase phase);
super.build_phase(phase);
start_time = new[500];
end_time = new[500];
endfunction: build_phase

virtual function void check_phase (uvm_phase phase);
super.check_phase(phase);

//j == end_time.size()-1;
//if (j== end_time.size()-1) begin
total_time = end_time[end_time.size()-1] - start_time [0];

$fdisplay(fd," total_time: %t", total_time); // writing into a file, fd is file handle
`uvm_info (get_full_name(),$sformatf(" total number of TLPs generated by the host in how much time is calculated"),UVM_LOW)

TLP_in_1sec = ((j)/(total_time))*10^9;
$fdisplay(fd," TLP_in_1sec: %t",TLP_in_1sec );
`uvm_info (get_full_name(),$sformatf(" total number of TLPs to be transmitted in 1sec is calculated"),UVM_LOW

end

endfunction:check_phase

is this a right method?

there is a correction it is : TLP_in_1sec = ((end_time.size()-1)/(total_time))*10^9;