Improved timing function for millisecond precision on Linux platform