Function to time how long the algorithm can train a network