Is there a way to calculate KPI for task completion in time
One option is to implement your own https://erpnext.com/docs/user/manual/en/customize-erpnext
But see what is available for example