Computer/Programming2009. 9. 11. 18:20

Milliseconds vs. FPS

I've come to the realization that many new graphics/game programmers don't know how to accurately measure the speed of their rendering. Most of them fall into the common pitfall of utilizing frames per second (FPS) as their method of profiling. This is the wrong thing to do.

많은 그래픽/게임 프로그래머들이 그들의 프로그램에서 랜더링 속도를 정확히 측정 모르더군요. 대부분이 frames per second(FPS) 속도 측정의 방법으로 사용하고 있는데 이는 정확한 방법이 아닙니다.


Let's see a little bit of the mathematics. First, the definition of millisecond, better visualized as .
We can now build a relationship between the frames per second and the number of milliseconds it takes to render one frame. The inverse of the frames per second gives us the number of seconds it takes to render one frame e.g. 1/2 FPS = 0.5 s, 1/10 FPS = 0.01 s, etc. Since there are 1,000 milliseconds in a second, we then multiply the value, given above, by 1,000 to retrieve the number of milliseconds it takes to render one frame.

잠깐 수학책을 들여다 봅시다. 우선 millisecond 정의 입니다.  이렇게 보면 명확해 보이죠. Frames per second 프레임을 랜더링 하기 위해 걸리는 milliseconds 대한 관계를 정리해 보겠습니다. Frames per second 역수는 프레임을 랜더링 하는데 초가 걸리는지를 말해줍니다. 예를 들어 1/(2 FPS) = 0.5s, 1/(10 FPS) = 0.01s 입니다. 1초는 1,000milliseconds이므로 위의 수에 1,000 곱하면 프레임에 milliseconds 걸리는지 계산이 됩니다.


Here's a graph that shows the number of milliseconds it takes to render one frame as a function of the frames per second:

아래는 FPS 프레임을 랜더링 하는데 milliseconds 걸리는지를 보여주는 그래프입니다.


As you can see, the two values are not linearly related. While the frames per second increase, the number of milliseconds decreases at a slower rate. (In mathematical terms, the limit of the function approaches 0.) What does this mean to the general programmer? The difference between 900 FPS and 870 FPS is negligible while the difference between 60 FPS and 30 FPS is quite noticeable.

보시는 것처럼 값은 1차원적으로 비례하지 않습니다. Frames per second 증가하지만 milliseconds 천천히 감소합니다(수학적 용어로 함수가 0으로 수렴한다고 합니다). 그래프가 의미 하는 뭘까요? 60FPS 30FPS 차이를 보이는 변화이지만 900FPS 870FPS 의미가 없다는 것입니다.


To conclude, I will give you a little real world example. Your program has a pixel shader that operates on 100 pixels giving you 1,000 FPS. You move closer to the object, now the pixel shader is operating on 150 pixels (50% more) and your framerate drops to 666 FPS. Some graphics programmers would think, "Oh no! I'm doing something wrong." With our new knowledge, this change is to be expected: We've gone from 1 millisecond to 1.5 milliseconds to render one frame. Given that we are shading 50% more pixels, this change in rendering speed is not bad at all.

결론으로 실제적인 예를 하나 들어 보이겠습니다. 100픽셀에 적용되고 있는 픽셀 셰이더가 포함된 프로그램을 만들었다고 생각해 봅시다. 물체에 다가갈수록 FPS 1,000에서 666으로 떨어지고 픽셀 셰이더는 150픽셀에(50% 많아졌습니다) 적용됩니다. 일부 그래픽 프로그래머는 .. 뭔가 잘못된 아냐?” 라고 생각할 있겠지만 우리는 이제 이런 변화가 당연하다고 받아들일 있습니다: 프레임을 랜더링 하는데 1millisecond에서 1.5milliseconds 느려졌지만 50% 많은 픽셀에 적용된 픽셀 셰이더를 생각해 보면 그다지 크게 느려지진 않은 겁니다..


Now get out there, use those milliseconds, and never stop the crusade to convert everyone from using FPS!

이제부터 milliseconds 사용하도록 하고 FPS 사용하는 사람들을 milliseconds 사용하도록 일깨워 줍시다!

Posted by J.sean