Copied timing code into main (sans testing)