add new function "calculate latency average"