Calculate some performance metrics
A bit more refactoring