How many FPS should I have for updating a custom progress bar?
I just wrote a custom开发者_如何学运维 progress bar, it's single buffered and will remain so. How many frames per second are desirable for something like this? I don't want to waste too much CPU updating the screen unnecessarily.
As a rule of thumb, 10 fps is a reasonable minimum for very small, simple animations with motion. 30 fps is a minimum for more complex motion and/or larger scenes.
However, generally progress bars have very little change from frame to frame. If you are using a very simple animation, you may find that less than 10fps works.
I suggest starting at 10fps and checking the result. Tune from there.
You might want to go the other way around and update the progress bar whenever there is a pixel of bar to update. If you have a 200 pixel bar, then update it when each 0.5% of the processing is completed. That’s every 300 ms for a 1 minute process but every 4.5 s for a 15 min process. As the examples indicate, the fps will generally be slower than you’d need for smooth large-motion animation; otherwise, you wouldn’t need a progress bar. Depending on your design, it may be easier to have the process announce to the progress bar each time it completes x% than to have the progress bar keep checking process every n ms.
I'd be happy with an update per second or two for functional purposes.
10-20 fps if you want it to look good.
精彩评论