Understanding calculation speed of different functions