I encountered a certain inconsistency in the speed the Pyglet's pyglet.clock.schedule and pyglet.clock.schedule_interval (with the interval argument below some value), call the functions.
Both commands seem to show some common treshold of the interval with what they can call the function. It could be associated with the hardware performance limits if the treshold speed wasn't THAT low - max. about 30 calls of a function per second.
The test code and results can be seen below:
import pyglet
from time import time
window = pyglet.window.Window()
last_update = time()
def update(dt):
global last_update
print("dt: ", dt)
print('Measured dt: ', time()-last_update)
last_update = time()
@window.event
def on_draw():
dt = pyglet.clock.tick()
print('Last clock tick: ', dt, "\n")
pyglet.clock.schedule(update)
pyglet.app.run()
The sample result:
dt: 0.030516604423768356
Measured dt: 0.03125262260437012
dt: 0.0007512663764779326
Measured dt: 0.0
Last clock tick: 0.0007512663764779326
Despite the dt = pyglet.clock.tick()
inducing to recall the update(dt)
function whose dt value states to be consistent with the expectated clock.tick()
returned value, the first call almost always returns the same, fixed dt's value, indicating the maximum frequency the Pyglet's interval functions call the callback function is about 30 - 32 times per second.
I'm not sure what may influence such a low frequency but I guess such performance may be an effect of some kind of a malfunction. The evidence seem to be at least the utilization of the higher framerates (e.g. 120 FPS) among the publishers' examplary programs.
What can be the reason for it working so slowly and could the pyglet's interval functions somehow be fixed to update the callback functions with the corresponding, given frequency, not limited to the modest ~30 per second? Thanks you for help in advance.
PS The clock.schedule_interval
can only be manipulated, if its interval is about above 1/30.
PPS The occurance of print methods doesn't influence the interval functions' treshold speed.