kame
kame

Reputation: 21940

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 Python? Thanks

Upvotes: 0

Views: 2011

Answers (3)

kame
kame

Reputation: 21940

i found it again. There is a rate()-function in the visual-module. you can use it in the while-loop.

Upvotes: 0

Rob Lourens
Rob Lourens

Reputation: 16089

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

Upvotes: 1

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

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.

Upvotes: 0

Related Questions