Time.time() shows different values

I’m using PYNQ-Z2 board and trying to transfer data using DMA. I’m interested in calculating the total time taken for the data send and receive. Below is the snippet of my code

start = time.time() 
dma_fifo.sendchannel.transfer(input_buffer)
dma_fifo.recvchannel.transfer(output_buffer)
dma_fifo.sendchannel.wait()
dma_fifo.recvchannel.wait()
end = time.time()
total_time = end-start
print(total_time)

But every time I run this, the total_time value for the same set of data keeps varying.
Why and how’s this happening? Is there some mistake in my approach in calculating the time taken for the data transfer? Or is there any better way to calculate time taken? Kindly help.

I think you should run the same program multiple times and take the average of the time consumed?

Yeah thank you, following that as of now. But what would the reason behind getting different values when nothing in PS/PL side inputs/code is changing?

This is not a real-time system, so you should not expect it to be deterministic.
How much variation do you see in the times you measure?

Cathal

Below is the set of values(total time taken) I got for the block of code i have posted in the question:

0.002197742462158203
0.0022864341735839844
0.002167940139770508
0.0022034645080566406
0.002228260040283203

Variation is in the range of 0.1 ms

I’d say this variation is normal.

Cathal