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 ;)
这是一个非常耗费成本的功能,让我的表现在我脚下消失吗?我猜他们使用那个用于主屏幕上的摇摆按钮+核心动画。在我开始浪费时间之前,我只想知道;)
5 个解决方案
#1
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.
与所有东西一样,它取决于你使用它的方式和数量。它一直在游戏开发中使用,iPhone非常适合。 CoreAnimation也非常快。如果您对此感到担心,我的建议是采用Apple提供的一个示例应用程序并通过Instruments运行它来预先形成一些您自己的基准测试,以确定它们是否可以满足您的需求。
#2
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.
似乎不太可能是一个性能问题 - 它可以解决像Cosine,Sine和一些乘法。不要每秒呼叫数千次,你会没事的。
#3
Very (very) little. This is also something you can easily measure yourself; see the following URLs for examples/information on implementing high-resolution timing:
很(非常)小。这也是你可以轻松衡量的东西;有关实现高分辨率计时的示例/信息,请参阅以下URL:
#4
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).
所有CGAffineTransformMakeRotation()都填充了常规旧CGAffineTransform的矩阵。如果你认为你可以自己更快地填充(或预填充)矩阵,那就去吧(如果不是已经超级优化的话,我真的会感到惊讶)。
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.
然后,当需要进行应用转换的实际工作时,我很确定GPU会被告知要处理它以便它能够快速运行并且你的主CPU不应该受到太大的影响。
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.
如果你真的很担心它,那么在OpenGL之上的2D空间中进行转换以确保它的硬件优化。
#5
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.
不要担心人们告诉你的个人电话很慢。如果代码很慢,请将此信息用作指针,但始终可以查看代码中的操作方式。
#1
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.
与所有东西一样,它取决于你使用它的方式和数量。它一直在游戏开发中使用,iPhone非常适合。 CoreAnimation也非常快。如果您对此感到担心,我的建议是采用Apple提供的一个示例应用程序并通过Instruments运行它来预先形成一些您自己的基准测试,以确定它们是否可以满足您的需求。
#2
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.
似乎不太可能是一个性能问题 - 它可以解决像Cosine,Sine和一些乘法。不要每秒呼叫数千次,你会没事的。
#3
Very (very) little. This is also something you can easily measure yourself; see the following URLs for examples/information on implementing high-resolution timing:
很(非常)小。这也是你可以轻松衡量的东西;有关实现高分辨率计时的示例/信息,请参阅以下URL:
#4
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).
所有CGAffineTransformMakeRotation()都填充了常规旧CGAffineTransform的矩阵。如果你认为你可以自己更快地填充(或预填充)矩阵,那就去吧(如果不是已经超级优化的话,我真的会感到惊讶)。
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.
然后,当需要进行应用转换的实际工作时,我很确定GPU会被告知要处理它以便它能够快速运行并且你的主CPU不应该受到太大的影响。
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.
如果你真的很担心它,那么在OpenGL之上的2D空间中进行转换以确保它的硬件优化。
#5
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.
不要担心人们告诉你的个人电话很慢。如果代码很慢,请将此信息用作指针,但始终可以查看代码中的操作方式。