frames per seconds
I want to limit the calculation-speed. There was a command for rate per second. Could anybody help me? doesn't rate() work in the newer version of 开发者_JAVA技巧Python? Thanks
Like Ignacio said, you can measure the time since the last calculation, calculate the time until the next, and sleep until then. You can also do it without any other framework, for example, with these functions:
from datetime import datetime
import time
t = datetime.now()[5] # milliseconds
dt = # do some calculation for time needed to sleep
time.sleep(dt) # sleep in seconds
Using an event loop framework such as Twisted will allow you to schedule your next calculation in the future once you have completed the current calculation, and to sleep until that time.
i found it again. There is a rate()-function in the visual-module. you can use it in the while-loop.
精彩评论