Updated to use clock_gettime instead of gettimeofday to measure running time.