Read my post on how to time a function on my programming interview series blog at http://www.programminginterviews.info/2012/07/how-to-time-any-function.html.