fix latecy calculation bugs

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>