Latency calculation