tags:

views:

269

answers:

5

Is that an very cost-intensive function that sucky my performance away under my feet? I guess they used that one for the waggling buttons on the home screen + core animation. I just want to know before I start wasting my time ;)

+1  A: 

Like with everything, it depends on how and how much you use it. It's used all the time in game development, which the iPhone is very well suited for. CoreAnimation is also very fast. If you're worried about it, my suggestion is to take one of the Apple-provided sample apps and run it through Instruments to preform some of your own benchmarks to see if they are acceptable for your needs.

Marc W
+3  A: 

Seems unlikely that it'd be much of a performance problem - it works out to something like a Cosine, a Sine, and a few multiplications. Don't call it thousands of times a second, and you'll be fine.

Mark Bessey
+1  A: 

All CGAffineTransformMakeRotation() does is fill in the matrix for a regular old CGAffineTransform. If you think you can fill (or pre-fill) the matrix faster yourself, then go for it (I'd be really surprised if this wasn't super-optimized already).

Then when it comes time to do the actual work of applying the transform, I'm pretty sure the GPU is told to take care of it so it'll run fast and your main CPU shouldn't take too much of a hit.

If you're really worried about it, then do the transforms in 2D space on top of OpenGL to make sure it's hardware optimized.

Ramin
Thanks. How would I do that in 2D space with OpenGL? I have no Idea about OpenGL. Always thought that's just for 3D stuff.
Thanks
+1  A: 

Very (very) little. This is also something you can easily measure yourself; see the following URLs for examples/information on implementing high-resolution timing:

landonf
A: 

I just want to know before I start wasting my time

Optimise the system not the individual lines. Who knows how many times your code will call the transform. Better to get the whole system working, profile it and then optimise the parts that are too slow.

Don't worry about individual calls that people tell you are slow. Use this information as a pointer if your code is slow but always see how the operate in your code.

Roger Nolan