how to time a function in scala