Added extra performance measurement code to debug mode.