Add a timing test and improve performance.
Add a timing test and improve performance.