Re: IOS floating point performance
Re: IOS floating point performance
- Subject: Re: IOS floating point performance
- From: David Rowland <email@hidden>
- Date: Thu, 08 Aug 2013 12:59:28 -0700
I ran it in Debug mode which should turn off most optimizations. I ran the loop 100 times and then 200 times. The latter took almost exactly twice the time as the former. The results are saved in instance variables of the C++ class this belongs to.
On Aug 8, 2013, at 12:06 PM, Sandy McGuffog <email@hidden> wrote:
> Be careful using that code as a test; a good optimizing compiler could pick up that sin is a library function without side effects, and no result is saved, and optimize that loop to two calls to adjustValueRadians.
>
> Sandy
>
> On Aug 8, 2013, at 8:17 PM, Thomas Wetmore <email@hidden> wrote:
>
>> David,
>>
>> Those are lightening speeds. So I agree with you wholeheartedly -- there is no sense in working on a custom table-driven approach. The current approach must already be table-based with speeds like that.
>>
>> Tom Wetmore
>>
>>
>> On Aug 8, 2013, at 1:26 PM, David Rowland <email@hidden> wrote:
>>
>>> I wrote an app that calculates the positions of Sun and Moon and other information as well. The heart of the Moon calculation is this. I added a loop around it and called a stopwatch at the beginning and end.
>>>
>>> startTime();
>>> for (int jj = 0; jj<100;++jj)
>>> {
>>> //in radians
>>> double lambda = 3.81040282295402 + 8399.70910754626 * T
>>> + 0.109781209950443 * sin(adjustValueRadians(2.35619449019234 + 8328.69146829639 * T))
>>> - 0.022165681500328 * sin(adjustValueRadians(4.5256387504213 - 7214.06294691607 * T))
>>>
>>> One hundred times through this loop, on my iPhone 5, took about 0.0028 seconds. Two hundred times took about 0.0056 sec.
>>>
>>> I infer that one pass takes about 0.000028 seconds, or 28.0 microseconds.
>>>
>>> The functions are probably very carefully written and could not be improved by table lookups, vector libraries, etc. That is barking up the wrong tree.
>>>
>>> David
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden